mirror of
https://github.com/appium/appium.git
synced 2026-05-19 18:09:14 -05:00
chore(support): ditch gulp
This PR builds and tests `@appium/support` without Gulp. Much like the changes to `appium`: - Test files reorganized and renamed - Tests run via `mocha` proper using `@babel/register` (no build needed) - Build run via `@babel/cli`
This commit is contained in:
+3
-2
@@ -25,11 +25,11 @@ module.exports = (wallaby) => {
|
||||
// below this are fixtures
|
||||
{
|
||||
binary: true,
|
||||
pattern: './packages/support/test/assets/sample_binary.plist',
|
||||
pattern: './packages/support/test/unit/assets/sample_binary.plist',
|
||||
},
|
||||
{
|
||||
instrument: false,
|
||||
pattern: './packages/support/test/assets/sample_text.plist',
|
||||
pattern: './packages/support/test/unit/assets/sample_text.plist',
|
||||
},
|
||||
{
|
||||
instrument: false,
|
||||
@@ -50,6 +50,7 @@ module.exports = (wallaby) => {
|
||||
'./packages/*/test/**/*-specs.js',
|
||||
'./packages/*/test/unit/**/*.spec.js',
|
||||
'!./packages/*/test/**/*-e2e-specs.js',
|
||||
'!./packages/*/test/e2e/**/*',
|
||||
'!./packages/*/node_modules/**',
|
||||
// this is more of an E2E test and it's tedious to run
|
||||
'!./packages/gulp-plugins/test/transpile-specs.js',
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const gulp = require('gulp');
|
||||
const boilerplate = require('@appium/gulp-plugins').boilerplate.use(gulp);
|
||||
|
||||
gulp.task('copy-files', () =>
|
||||
gulp.src('./test/assets/*').pipe(gulp.dest('./build/test/assets/')));
|
||||
|
||||
boilerplate({
|
||||
build: '@appium/support',
|
||||
coverage: {
|
||||
files: [
|
||||
'./build/test/**/*-specs.js',
|
||||
'!./build/test/assets/**',
|
||||
'!./build/test/images/**',
|
||||
'!./build/test/**/*-e2e-specs.js'
|
||||
],
|
||||
verbose: true,
|
||||
},
|
||||
postTranspile: ['copy-files']
|
||||
});
|
||||
@@ -32,10 +32,13 @@
|
||||
"build"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "gulp dev --no-notif",
|
||||
"build": "gulp transpile",
|
||||
"test": "gulp unit-test:run",
|
||||
"test:e2e": "gulp e2e-test:run"
|
||||
"build": "babel lib --root-mode=upward --delete-dir-on-start --out-dir=build/lib",
|
||||
"dev": "npm run build -- --watch",
|
||||
"fix": "npm run lint -- --fix",
|
||||
"lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
|
||||
"test": "npm run test:unit",
|
||||
"test:e2e": "mocha --require ../../test/setup-babel.js --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
|
||||
"test:unit": "mocha --require ../../test/setup-babel.js \"./test/unit/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "7.16.3",
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// @ts-check
|
||||
|
||||
import path from 'path';
|
||||
import {fs, tempDir} from '../lib';
|
||||
import { fs, tempDir } from '../../lib';
|
||||
import {
|
||||
DEFAULT_APPIUM_HOME,
|
||||
readPackageInDir,
|
||||
resolveAppiumHome,
|
||||
resolveManifestPath,
|
||||
} from '../lib/env';
|
||||
} from '../../lib/env';
|
||||
|
||||
const {expect} = chai;
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
import {
|
||||
base64ToImage, imageToBase64, cropImage,
|
||||
getJimpImage, MIME_PNG,
|
||||
} from '../lib/image-util';
|
||||
} from '../../lib/image-util';
|
||||
import path from 'path';
|
||||
import _ from 'lodash';
|
||||
import { fs } from '../lib';
|
||||
import { fs } from '../../lib';
|
||||
|
||||
|
||||
const FIXTURES_ROOT = path.resolve(__dirname, '..', '..', 'test', 'images');
|
||||
const FIXTURES_ROOT = path.resolve(__dirname, 'fixture', 'images');
|
||||
|
||||
async function getImage (name) {
|
||||
const imagePath = path.resolve(FIXTURES_ROOT, name);
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
import { mjpeg } from '../lib';
|
||||
import { mjpeg } from '../../lib';
|
||||
import B from 'bluebird';
|
||||
import http from 'http';
|
||||
import mJpegServer from 'mjpeg-server';
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path';
|
||||
import { downloadFile } from '../lib/net';
|
||||
import { tempDir, fs } from '../lib/index';
|
||||
import { downloadFile } from '../../lib/net';
|
||||
import { tempDir, fs } from '../../lib/index';
|
||||
|
||||
|
||||
describe('#net', function () {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { node } from '../lib';
|
||||
import { node } from '../../lib';
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import B from 'bluebird';
|
||||
import path from 'path';
|
||||
import * as util from '../lib/util';
|
||||
import { tempDir, fs } from '../lib/index';
|
||||
import * as util from '../../lib/util';
|
||||
import { tempDir, fs } from '../../lib/index';
|
||||
|
||||
|
||||
describe('#util', function () {
|
||||
@@ -1,7 +1,7 @@
|
||||
import path from 'path';
|
||||
import * as zip from '../lib/zip';
|
||||
import { tempDir, fs } from '../lib/index';
|
||||
import { MockReadWriteStream } from './helpers';
|
||||
import * as zip from '../../lib/zip';
|
||||
import { tempDir, fs } from '../../lib/index';
|
||||
import { MockReadWriteStream } from '../helpers';
|
||||
|
||||
|
||||
describe('#zip', function () {
|
||||
@@ -2,25 +2,25 @@
|
||||
// @ts-check
|
||||
|
||||
import path from 'path';
|
||||
import {rewiremock} from './helpers';
|
||||
import {initMocks} from './mocks';
|
||||
import {rewiremock} from '../helpers';
|
||||
import {initMocks} from '../mocks';
|
||||
|
||||
const {expect} = chai;
|
||||
|
||||
describe('env', function () {
|
||||
/** @type {typeof import('../lib/env')} */
|
||||
/** @type {typeof import('../../lib/env')} */
|
||||
let env;
|
||||
|
||||
/** @type {sinon.SinonSandbox} */
|
||||
let sandbox;
|
||||
|
||||
/** @type {import('./mocks').MockPkgDir} */
|
||||
/** @type {import('../mocks').MockPkgDir} */
|
||||
let MockPkgDir;
|
||||
|
||||
/** @type {import('./mocks').MockReadPkg} */
|
||||
/** @type {import('../mocks').MockReadPkg} */
|
||||
let MockReadPkg;
|
||||
|
||||
/** @type {import('./mocks').MockTeenProcess} */
|
||||
/** @type {import('../mocks').MockTeenProcess} */
|
||||
let MockTeenProcess;
|
||||
|
||||
/** @type {string|undefined} */
|
||||
@@ -36,7 +36,7 @@ describe('env', function () {
|
||||
envAppiumHome = process.env.APPIUM_HOME;
|
||||
delete process.env.APPIUM_HOME;
|
||||
|
||||
env = rewiremock.proxy(() => require('../lib/env'), overrides);
|
||||
env = rewiremock.proxy(() => require('../../lib/env'), overrides);
|
||||
});
|
||||
|
||||
describe('resolveManifestPath()', function () {
|
||||
@@ -1,5 +1,6 @@
|
||||
import { fs, tempDir } from '../lib/index.js';
|
||||
import { fs, tempDir } from '../../lib/index.js';
|
||||
import path from 'path';
|
||||
import { createSandbox } from 'sinon';
|
||||
import { exec } from 'teen_process';
|
||||
import _ from 'lodash';
|
||||
|
||||
@@ -12,6 +13,15 @@ describe('fs', function () {
|
||||
|
||||
const existingPath = __filename;
|
||||
|
||||
let sandbox;
|
||||
beforeEach(function () {
|
||||
sandbox = createSandbox();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
describe('mkdir()', function () {
|
||||
let dirName = path.resolve(__dirname, 'tmp');
|
||||
|
||||
@@ -141,7 +151,7 @@ describe('fs', function () {
|
||||
});
|
||||
});
|
||||
it('glob()', async function () {
|
||||
let glob = '*-specs.js';
|
||||
let glob = '*.spec.js';
|
||||
let tests = await fs.glob(glob, {cwd: __dirname});
|
||||
tests.should.be.an('array');
|
||||
tests.should.have.length.above(2);
|
||||
@@ -152,16 +162,13 @@ describe('fs', function () {
|
||||
await chai.expect(fs.walkDir(__dirname, true, (item) => item.endsWith('logger/helpers.js'))).to.eventually.not.be.null;
|
||||
});
|
||||
it('should walk all elements recursive', async function () {
|
||||
await chai.expect(fs.walkDir(path.join(__dirname, 'fixture'), true, _.noop)).to.eventually.be.null;
|
||||
await chai.expect(fs.walkDir(path.join(__dirname, '..', 'e2e', 'fixture'), true, _.noop)).to.eventually.be.null;
|
||||
});
|
||||
it('should throw error through callback', async function () {
|
||||
let processed = 0;
|
||||
await chai.expect(fs.walkDir(__dirname, true,
|
||||
() => {
|
||||
++processed;
|
||||
throw 'Callback error';
|
||||
})).to.be.rejectedWith('Callback error');
|
||||
processed.should.equal(1);
|
||||
const err = new Error('Callback error');
|
||||
const stub = sandbox.stub().rejects(err);
|
||||
await (fs.walkDir(__dirname, true, stub)).should.eventually.be.rejectedWith(err);
|
||||
stub.should.have.been.calledOnce;
|
||||
});
|
||||
it('should traverse non-recursively', async function () {
|
||||
const filePath = await fs.walkDir(__dirname, false, (item) => item.endsWith('logger/helpers.js'));
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import AppiumSupport from '../lib/index.js';
|
||||
import AppiumSupport from '../../lib/index.js';
|
||||
|
||||
let { system, tempDir, util } = AppiumSupport;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { fs } from '../lib/index';
|
||||
import { fs } from '../../lib/index';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { SecureValuesPreprocessor } from '../lib/log-internal';
|
||||
import { SecureValuesPreprocessor } from '../../lib/log-internal';
|
||||
|
||||
|
||||
const CONFIG_PATH = path.resolve(os.tmpdir(), 'rules.json');
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import sinon from 'sinon';
|
||||
import _ from 'lodash';
|
||||
import { logger } from '../../lib';
|
||||
import { logger } from '../../../lib';
|
||||
|
||||
|
||||
let sandbox;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { node } from '../lib';
|
||||
import { node } from '../../lib';
|
||||
|
||||
describe('node utilities', function () {
|
||||
describe('getObjectSize', function () {
|
||||
@@ -1,6 +1,6 @@
|
||||
// transpile:mocha
|
||||
|
||||
import {NPM} from '../lib/npm';
|
||||
import {NPM} from '../../lib/npm';
|
||||
|
||||
describe('npm', function () {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from 'path';
|
||||
import { plist, tempDir, fs } from '../lib/index.js';
|
||||
import { plist, tempDir, fs } from '../../lib/index.js';
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as teenProcess from 'teen_process';
|
||||
import { createSandbox } from 'sinon';
|
||||
import { process } from '../lib/index.js';
|
||||
import { process } from '../../lib/index.js';
|
||||
import { retryInterval } from 'asyncbox';
|
||||
|
||||
const SubProcess = teenProcess.SubProcess;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { system } from '../lib/index.js';
|
||||
import { system } from '../../lib/index.js';
|
||||
import os from 'os';
|
||||
import { createSandbox } from 'sinon';
|
||||
import * as teen_process from 'teen_process';
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import { tempDir, fs } from '../lib/index.js';
|
||||
import { tempDir, fs } from '../../lib/index.js';
|
||||
|
||||
|
||||
describe('tempdir', function () {
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { createSandbox } from 'sinon';
|
||||
import { timing } from '../lib';
|
||||
import { timing } from '../../lib';
|
||||
|
||||
|
||||
const expect = chai.expect;
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import { util, fs, tempDir } from '../lib';
|
||||
import { util, fs, tempDir } from '../../lib';
|
||||
import B from 'bluebird';
|
||||
import { createSandbox } from 'sinon';
|
||||
import os from 'os';
|
||||
Reference in New Issue
Block a user