From 98f52e4ab2f2335563ee10e685c4450f86df7b9d Mon Sep 17 00:00:00 2001 From: Wil Wilsman Date: Mon, 13 May 2024 20:18:45 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Update=20moonshiner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 174 ++++++++++++++++++++++++++++--------------- package.json | 4 +- tests/helpers.js | 18 ++--- tests/index.js | 8 +- tests/run.js | 46 ------------ tests/test.config.js | 26 +++++++ 6 files changed, 153 insertions(+), 123 deletions(-) delete mode 100644 tests/run.js create mode 100644 tests/test.config.js diff --git a/package-lock.json b/package-lock.json index f79c42bc..b55080b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "eslint-plugin-n": "^16.6.2", "eslint-plugin-promise": "^6.1.1", "istanbul-lib-coverage": "^3.2.2", - "moonshiner": "^0.15.2", + "moonshiner": "^1.0.0-beta.9", "nyc": "^15.1.0", "rollup": "^4.9.6", "rollup-plugin-glob-import": "^0.5.0", @@ -2651,9 +2651,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.11.16", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.16.tgz", - "integrity": "sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==", + "version": "20.12.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz", + "integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==", "dev": true, "optional": true, "dependencies": { @@ -2984,6 +2984,52 @@ "dev": true, "license": "MIT" }, + "node_modules/bare-events": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.2.2.tgz", + "integrity": "sha512-h7z00dWdG0PYOQEvChhOSWvOfkIKsdZGkWr083FgN/HyoQuebSew/cgirYqh9SCuy/hRvxc5Vy6Fw8xAmYHLkQ==", + "dev": true, + "optional": true + }, + "node_modules/bare-fs": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.3.0.tgz", + "integrity": "sha512-TNFqa1B4N99pds2a5NYHR15o0ZpdNKbAeKTE/+G6ED/UeOavv8RY3dr/Fu99HW3zU3pXpo2kDNO8Sjsm2esfOw==", + "dev": true, + "optional": true, + "dependencies": { + "bare-events": "^2.0.0", + "bare-path": "^2.0.0", + "bare-stream": "^1.0.0" + } + }, + "node_modules/bare-os": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-2.3.0.tgz", + "integrity": "sha512-oPb8oMM1xZbhRQBngTgpcQ5gXw6kjOaRsSWsIeNyRxGed2w/ARyP7ScBYpWR1qfX2E5rS3gBw6OWcSQo+s+kUg==", + "dev": true, + "optional": true + }, + "node_modules/bare-path": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-2.1.2.tgz", + "integrity": "sha512-o7KSt4prEphWUHa3QUwCxUI00R86VdjiuxmJK0iNVDHYPGo+HsDaVCnqCmPbf/MiW1ok8F4p3m8RTHlWk8K2ig==", + "dev": true, + "optional": true, + "dependencies": { + "bare-os": "^2.1.0" + } + }, + "node_modules/bare-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-1.0.0.tgz", + "integrity": "sha512-KhNUoDL40iP4gFaLSsoGE479t0jHijfYdIcxRn/XtezA2BaUD0NRf/JGRpsMq6dMNM+SrCrB0YSSo/5wBY4rOQ==", + "dev": true, + "optional": true, + "dependencies": { + "streamx": "^2.16.1" + } + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -5376,6 +5422,21 @@ "node": ">=8.6" } }, + "node_modules/mime": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.3.tgz", + "integrity": "sha512-KgUb15Oorc0NEKPbvfa0wRU+PItIEZmiv+pyAO2i0oTIVTJhlzMclU7w4RXWQrSOVH5ax/p/CkIO7KI4OyFJTQ==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa" + ], + "bin": { + "mime": "bin/cli.js" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -5399,33 +5460,32 @@ } }, "node_modules/minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.1.tgz", + "integrity": "sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA==", "dev": true, "engines": { "node": ">=16 || 14 >=14.17" } }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true - }, "node_modules/moonshiner": { - "version": "0.15.2", - "resolved": "https://registry.npmjs.org/moonshiner/-/moonshiner-0.15.2.tgz", - "integrity": "sha512-We0UGfIErQ02+RWiHA61aGKr0CrDZa8vW2SWrUADptBwwIZ+UwVSZP3CujcPbwVm9cmIRYuEFSobgvm+N4kEVw==", + "version": "1.0.0-beta.9", + "resolved": "https://registry.npmjs.org/moonshiner/-/moonshiner-1.0.0-beta.9.tgz", + "integrity": "sha512-DuPdksBONARKqQLydFrg0tBjNeXMI8lRekIuLWsR8A3Gq77J8KSKodVbqLEQ1Hd+0t23Rpzi9D9/1cS8scbAPA==", "dev": true, "dependencies": { "cross-spawn": "^7.0.3", "extract-zip": "^2.0.1", - "odiff-bin": "^2.6.1", + "glob": "^10.3.12", + "mime": "^4.0.1", "rimraf": "^5.0.1", "tar-fs": "^3.0.3", "unbzip2-stream": "^1.4.3", "ws": "^8.13.0" + }, + "bin": { + "moonshiner": "bin/moonshiner", + "test": "bin/moonshiner" } }, "node_modules/moonshiner/node_modules/brace-expansion": { @@ -5454,31 +5514,31 @@ } }, "node_modules/moonshiner/node_modules/glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", + "version": "10.3.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.15.tgz", + "integrity": "sha512-0c6RlJt1TICLyvJYIApxb8GsXoai0KUP7AxKKAtsYXdgJR1mGEUa7DgwShbdk1nly0PYoZj01xd4hzbq3fsjpw==", "dev": true, "dependencies": { "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", + "jackspeak": "^2.3.6", "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" + "minipass": "^7.0.4", + "path-scurry": "^1.11.0" }, "bin": { "glob": "dist/esm/bin.mjs" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/moonshiner/node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -5491,9 +5551,9 @@ } }, "node_modules/moonshiner/node_modules/rimraf": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", - "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", + "version": "5.0.7", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", + "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", "dev": true, "dependencies": { "glob": "^10.3.7" @@ -5502,7 +5562,7 @@ "rimraf": "dist/esm/bin.mjs" }, "engines": { - "node": ">=14" + "node": ">=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -5679,16 +5739,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/odiff-bin": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/odiff-bin/-/odiff-bin-2.6.1.tgz", - "integrity": "sha512-SeI3ehAqjQUMlUkGjvIFGKoHZIO3zG1N1wMRhf7ojM7Vb+HcyB2RKSSCu7kbvYVtSdZADEBSJ7nvP/d7iBLivA==", - "dev": true, - "hasInstallScript": true, - "bin": { - "odiff": "bin/odiff" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -5834,25 +5884,25 @@ "license": "MIT" }, "node_modules/path-scurry": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", - "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", "dev": true, "dependencies": { - "lru-cache": "^9.1.1 || ^10.0.0", + "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", - "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz", + "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", "dev": true, "engines": { "node": "14 || >=16.14" @@ -6401,13 +6451,16 @@ "license": "BSD-3-Clause" }, "node_modules/streamx": { - "version": "2.15.7", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.7.tgz", - "integrity": "sha512-NPEKS5+yjyo597eafGbKW5ujh7Sm6lDLHZQd/lRSz6S0VarpADBJItqfB4PnwpS+472oob1GX5cCY9vzfJpHUA==", + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.16.1.tgz", + "integrity": "sha512-m9QYj6WygWyWa3H1YY69amr4nVgy61xfjys7xO7kviL5rfIEc2naf+ewFiOA+aEJD7y0JO3h2GoiUv4TDwEGzQ==", "dev": true, "dependencies": { "fast-fifo": "^1.1.0", "queue-tick": "^1.0.1" + }, + "optionalDependencies": { + "bare-events": "^2.2.0" } }, "node_modules/string-width": { @@ -6559,14 +6612,17 @@ } }, "node_modules/tar-fs": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.4.tgz", - "integrity": "sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.6.tgz", + "integrity": "sha512-iokBDQQkUyeXhgPYaZxmczGPhnhXZ0CmrqI+MOb/WFGS9DW5wnfrLgtjUJBvz50vQ3qfRwJ62QVoCFu8mPVu5w==", "dev": true, "dependencies": { - "mkdirp-classic": "^0.5.2", "pump": "^3.0.0", "tar-stream": "^3.1.5" + }, + "optionalDependencies": { + "bare-fs": "^2.1.1", + "bare-path": "^2.1.0" } }, "node_modules/tar-stream": { @@ -7005,9 +7061,9 @@ } }, "node_modules/ws": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", - "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz", + "integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==", "dev": true, "engines": { "node": ">=10.0.0" diff --git a/package.json b/package.json index 2bd4135a..fe294856 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "test": "npm run lint && npm run test:coverage", "test:coverage": "nyc npm run test:only", "test:debug": "npm run test:only -- --debug", - "test:only": "NODE_ENV=test node tests/run.js", + "test:only": "NODE_ENV=test npx moonshiner", "test:types": "tsc --project tests", "lint": "eslint --ignore-path .gitignore --ignore-pattern www ." }, @@ -44,7 +44,7 @@ "eslint-plugin-n": "^16.6.2", "eslint-plugin-promise": "^6.1.1", "istanbul-lib-coverage": "^3.2.2", - "moonshiner": "^0.15.2", + "moonshiner": "^1.0.0-beta.9", "nyc": "^15.1.0", "rollup": "^4.9.6", "rollup-plugin-glob-import": "^0.5.0", diff --git a/tests/helpers.js b/tests/helpers.js index 9a857a36..a9b52153 100644 --- a/tests/helpers.js +++ b/tests/helpers.js @@ -1,4 +1,3 @@ -import { createTestHook } from 'moonshiner/utils'; import { Interactor } from 'interactor.js'; // Test interactor scoped to the testing fixtures @@ -8,20 +7,21 @@ export const I = new Interactor({ }); // Test hook which sets up and tears down HTML fixtures -export const fixture = createTestHook(innerHTML => { - let $test = document.createElement('div'); +export const fixture = innerHTML => { + // clean up any existing testing-root + document.getElementById('testing-root')?.remove(); // format HTML to remove extraneous spaces let ind = innerHTML.match(/^\n(\s*)/)?.[1]?.length; innerHTML = innerHTML.replace(new RegExp(`^\\s{${ind}}`, 'mg'), '').trim(); // assign HTML and append to the body - Object.assign($test, { id: 'testing-root', innerHTML }); - document.body.appendChild($test); - - // return a cleanup function - return () => $test.remove(); -}); + document.body.appendChild( + Object.assign(document.createElement('div'), { + id: 'testing-root', + innerHTML + })); +}; // Test helper to create an event listener spy export function listen(selector, event, fn) { diff --git a/tests/index.js b/tests/index.js index baa6e388..79e75c2d 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,7 +1 @@ -import { use, configure, run } from 'moonshiner'; -import reporters from 'moonshiner/reporters'; - -use(reporters.remote()); -configure({ timeout: 10_000 }); - -import('./**/*.test.js').then(run); +import('./**/*.test.js'); diff --git a/tests/run.js b/tests/run.js deleted file mode 100644 index 098bfe6a..00000000 --- a/tests/run.js +++ /dev/null @@ -1,46 +0,0 @@ -import createTestServer from 'moonshiner/server'; -import middlewares from 'moonshiner/middlewares'; -import reporters from 'moonshiner/reporters'; -import launch from 'moonshiner/launchers'; -import cov from 'istanbul-lib-coverage'; - -// create test server -const testServer = createTestServer({ - debug: process.argv.includes('--debug') -}); - -// use reporters -testServer.use(reporters.emoji()); -testServer.use(reporters.coverage({ - map: cov.createCoverageMap() -})); - -// use launchers (firefox via flag, chrome by default) -if (process.argv.includes('--firefox')) - testServer.use(launch.firefox()); -else testServer.use(launch.chrome()); - -// use bundler -testServer.use(middlewares.listen(async () => { - let { rollup } = await import('rollup'); - let { test: config } = await import('../rollup.config.js'); - - let bundle = await rollup(config); - let { output } = await bundle.generate(config.output); - - // serve bundle output - testServer.use(middlewares.serve({ - virtual: output.reduce((virtual, output) => { - let { fileName, code, source } = output; - virtual[`/${fileName}`] = code ?? source; - return virtual; - }, {}) - })); - - return async () => { - await bundle.close(); - }; -})); - -// start test server -testServer.listen(); diff --git a/tests/test.config.js b/tests/test.config.js new file mode 100644 index 00000000..addbaa42 --- /dev/null +++ b/tests/test.config.js @@ -0,0 +1,26 @@ +export default { + browser: 'Chrome', + timeout: 10_000, + + plugins: [ + async test => { + const { rollup } = await import('rollup'); + const { test: config } = await import('../rollup.config.js'); + + let bundle = await rollup(config); + let { output } = await bundle.generate(config.output); + + test.configure({ + serve: output.reduce((virtual, output) => { + let { fileName, code, source } = output; + virtual[`/${fileName}`] = code ?? source; + return virtual; + }, {}) + }); + + test.on('test:abort', async () => { + await bundle.close(); + }); + } + ] +};