diff --git a/.mocharc.yaml b/.mocharc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8352bc079b71bd3f01f7e7b449f02c304b9a7867_Lm1vY2hhcmMueWFtbA== --- /dev/null +++ b/.mocharc.yaml @@ -0,0 +1,4 @@ +slow: 1000 +timeout: 5000 +file: +- test/index.spec.js diff --git a/.npmignore b/.npmignore index bd043a5a3274767b8bb15d0ce5f91dedfba1e005_Lm5wbWlnbm9yZQ==..8352bc079b71bd3f01f7e7b449f02c304b9a7867_Lm5wbWlnbm9yZQ== 100644 --- a/.npmignore +++ b/.npmignore @@ -10,3 +10,4 @@ .hgignore .nycrc.yaml *.tgz +*.map diff --git a/.nycrc.yaml b/.nycrc.yaml index bd043a5a3274767b8bb15d0ce5f91dedfba1e005_Lm55Y3JjLnlhbWw=..8352bc079b71bd3f01f7e7b449f02c304b9a7867_Lm55Y3JjLnlhbWw= 100644 --- a/.nycrc.yaml +++ b/.nycrc.yaml @@ -1,7 +1,3 @@ -# all: true -include: -- commonjs/**/*.js -- esm/**/*.mjs reporter: - lcov - text diff --git a/package.json b/package.json index bd043a5a3274767b8bb15d0ce5f91dedfba1e005_cGFja2FnZS5qc29u..8352bc079b71bd3f01f7e7b449f02c304b9a7867_cGFja2FnZS5qc29u 100644 --- a/package.json +++ b/package.json @@ -20,5 +20,5 @@ "scripts": { "build": "patch-package && rimraf esm commonjs && npm-run-all --parallel build:*", "build:esm": "BABEL_ENV=esm babel -d esm src --keep-file-extension", - "build:commonjs": "BABEL_ENV=commonjs babel -d commonjs src", + "build:commonjs": "BABEL_ENV=commonjs babel --source-maps -d commonjs src", "test:code-check": "eslint --ext js,mjs,cjs --format gitlab .", @@ -24,5 +24,5 @@ "test:code-check": "eslint --ext js,mjs,cjs --format gitlab .", - "test:functional": "nyc mocha --slow 500 --timeout 5000 test/index.js && rimraf .nyc_output", + "test:functional": "rimraf coverage && nyc mocha && rimraf .nyc_output", "test": "npm run build && npm-run-all --parallel test:*", "prepare": "cd test && npm i --no-package-lock", "prepublishOnly": "npm run test" diff --git a/test/index.js b/test/index.spec.js similarity index 97% rename from test/index.js rename to test/index.spec.js index bd043a5a3274767b8bb15d0ce5f91dedfba1e005_dGVzdC9pbmRleC5qcw==..8352bc079b71bd3f01f7e7b449f02c304b9a7867_dGVzdC9pbmRleC5zcGVjLmpz 100644 --- a/test/index.js +++ b/test/index.spec.js @@ -10,7 +10,7 @@ const expect = chai.expect chai.use(chaiAsPromised) -const loadConfig = require('./load-config') +const loadConfig = require('./worker/load-config') const wrapTests = file => { const testInfo = YAML.parse(readFileSync(resolve(__dirname, file), 'utf8')) diff --git a/test/package.json b/test/package.json index bd043a5a3274767b8bb15d0ce5f91dedfba1e005_dGVzdC9wYWNrYWdlLmpzb24=..8352bc079b71bd3f01f7e7b449f02c304b9a7867_dGVzdC9wYWNrYWdlLmpzb24= 100644 --- a/test/package.json +++ b/test/package.json @@ -2,5 +2,8 @@ "name": "test", "dependencies": { "config.io": "file:.." + }, + "scripts": { + "test": "cd .. && npm test" } } diff --git a/test/load-config.js b/test/worker/load-config.js similarity index 100% rename from test/load-config.js rename to test/worker/load-config.js diff --git a/test/load-worker.js b/test/worker/load-worker.js similarity index 100% rename from test/load-worker.js rename to test/worker/load-worker.js diff --git a/test/load-worker.mjs b/test/worker/load-worker.mjs similarity index 100% rename from test/load-worker.mjs rename to test/worker/load-worker.mjs diff --git a/test/run-test.js b/test/worker/run-test.js similarity index 79% rename from test/run-test.js rename to test/worker/run-test.js index bd043a5a3274767b8bb15d0ce5f91dedfba1e005_dGVzdC9ydW4tdGVzdC5qcw==..8352bc079b71bd3f01f7e7b449f02c304b9a7867_dGVzdC93b3JrZXIvcnVuLXRlc3QuanM= 100644 --- a/test/run-test.js +++ b/test/worker/run-test.js @@ -1,6 +1,14 @@ const _ = require('lodash') const { parentPort, workerData } = require('worker_threads') +const postMessage = msg => { + if (!parentPort || !parentPort.postMessage) { + console.error('Impossible to post message, missing postMessage', msg) + return + } + parentPort.postMessage(msg) +} + const run = async (configIO, workerData) => { if (workerData.start) { if (!workerData.await) { @@ -27,8 +35,8 @@ break } - (parentPort?.postMessage.bind(parentPort) || console.log)(data) + postMessage(data) } module.exports = async configIO => { try { @@ -31,6 +39,6 @@ } module.exports = async configIO => { try { - await run(configIO, workerData) + await run(configIO, workerData || {}) } catch (err) { @@ -36,4 +44,4 @@ } catch (err) { - parentPort.postMessage(err) + postMessage(err) } }