chore(gulp-plugins): fix tests; override mocha and run with babel
`@appium/gulp-plugins` needs babel to run its tests, apparently.
MODIFY
package-lock.json
package-lock.json
"@babel/core": "^7.0.0-0"
}
},
+ "node_modules/@babel/register": {
+ "version": "7.18.9",
+ "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.18.9.tgz",
+ "integrity": "sha512-ZlbnXDcNYHMR25ITwwNKT88JiaukkdVj/nG7r3wnuXkOTHc60Uy05PwMCPre0hSkY68E6zK3xz+vUJSP2jWmcw==",
+ "dev": true,
+ "dependencies": {
+ "clone-deep": "^4.0.1",
+ "find-cache-dir": "^2.0.0",
+ "make-dir": "^2.1.0",
+ "pirates": "^4.0.5",
+ "source-map-support": "^0.5.16"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ }
+ },
"node_modules/@babel/runtime": {
"version": "7.20.1",
"license": "MIT",
"version": "2.0.0",
"license": "MIT"
},
+ "node_modules/find-cache-dir": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz",
+ "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==",
+ "dev": true,
+ "dependencies": {
+ "commondir": "^1.0.1",
+ "make-dir": "^2.0.0",
+ "pkg-dir": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/find-cache-dir/node_modules/find-up": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
+ "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
+ "dev": true,
+ "dependencies": {
+ "locate-path": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/find-cache-dir/node_modules/locate-path": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
+ "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
+ "dev": true,
+ "dependencies": {
+ "p-locate": "^3.0.0",
+ "path-exists": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/find-cache-dir/node_modules/p-limit": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
+ "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
+ "dev": true,
+ "dependencies": {
+ "p-try": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/find-cache-dir/node_modules/p-locate": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
+ "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
+ "dev": true,
+ "dependencies": {
+ "p-limit": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/find-cache-dir/node_modules/path-exists": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
+ "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==",
+ "dev": true,
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/find-cache-dir/node_modules/pkg-dir": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz",
+ "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==",
+ "dev": true,
+ "dependencies": {
+ "find-up": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/find-up": {
"version": "5.0.0",
"license": "MIT",
"node": ">=0.10.0"
}
},
+ "node_modules/pirates": {
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz",
+ "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==",
+ "dev": true,
+ "engines": {
+ "node": ">= 6"
+ }
+ },
"node_modules/pixelmatch": {
"version": "4.0.2",
"license": "ISC",
"vinyl-paths": "3.0.1",
"yargs": "17.6.2"
},
+ "devDependencies": {
+ "@babel/register": "7.18.9"
+ },
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
"npm": ">=8"

ADD
packages/gulp-plugins/.mocharc.js
+// @ts-check
+
+'use strict';
+
+module.exports = {
+ require: [require.resolve('./test/setup.js')],
+ // forbids use of .only() in CI
+ forbidOnly: Boolean(process.env.CI),
+ // increase default timeout for CI since it can be slow
+ timeout: process.env.CI ? '5s' : '2s',
+};

MODIFY
packages/gulp-plugins/package.json
packages/gulp-plugins/package.json
"build"
],
"scripts": {
+ "build": "gulp transpile",
"clean": "npx rimraf build",
"dev": "gulp dev --no-notif",
- "build": "gulp transpile",
"prepare": "npm run build",
"test": "gulp unit-test:run",
"test:e2e": "gulp e2e-test:run",
"vinyl-paths": "3.0.1",
"yargs": "17.6.2"
},
+ "devDependencies": {
+ "@babel/register": "7.18.9"
+ },
"peerDependencies": {
"gulp": "^4.0.2"
},

ADD
packages/gulp-plugins/test/setup.js
+'use strict';
+
+/**
+ * Mocha will load this file to configure the environment to use Chai as the
+ * assertion library. Since Chai is a singleton, we can run into problems when
+ * running files individually, if we have not carefully configured Chai in every
+ * single test file. This file means less boilerplate and less random test
+ * failures when running single test files.
+ *
+ * For simplicity, this file is _not_ transpiled. If it were, Mocha would need
+ * to load different versions of this file depending on the test context (are we
+ * running tests against the distfiles, or the source files?).
+ *
+ */
+
+// This configures @babel/register to look for a babel config in parent dir(s) of
+// wherever the tests are run. This is required if running tests via `mocha` in a package dir
+// instead of the monorepo root. This does not affect `gulp-mocha`, since it has its own `.babelrc`.
+// This file is required _in addition to_ the monorepo root's `test/setup.js`.
+
+require('@babel/register')();
+
+const chai = require('chai');
+const chaiAsPromised = require('chai-as-promised');
+const sinonChai = require('sinon-chai');
+
+// The `chai` global is set if a test needs something special.
+// Most tests won't need this.
+global.chai = chai.use(chaiAsPromised).use(sinonChai);
+
+// `should()` is only necessary when working with some `null` or `undefined` values.
+global.should = chai.should();

MODIFY
packages/gulp-plugins/test/transpile-specs.js
packages/gulp-plugins/test/transpile-specs.js
@@ -90,7 +90,7 @@ describe('transpile-specs', function () {
it(`should use sourcemap when throwing within mocha (${name})`, async function () {
const [stdout, stderr] = await exec(
- `${MOCHA} build-fixtures/test/${files.classFile}-throw-specs.js`
+ `${MOCHA} --no-color build-fixtures/test/${files.classFile}-throw-specs.js`
);
print(stdout, stderr);
let output = stdout + stderr;

chore(gulp-plugins): fix tests; override mocha and run with babel

`@appium/gulp-plugins` needs babel to run its tests, apparently.