From 50e8727111c0e8dcf88228d58e8ab92d11b7d106 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 13:04:40 +0200 Subject: [PATCH 1/5] refactor(test): add command to run an unique test and support Mocha Explorer extension --- .mocharc.yml | 11 +++++++++++ .vscode/settings.json | 5 ++++- package.json | 2 ++ yarn.lock | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .mocharc.yml diff --git a/.mocharc.yml b/.mocharc.yml new file mode 100644 index 00000000..c19fe15a --- /dev/null +++ b/.mocharc.yml @@ -0,0 +1,11 @@ +require: + - source-map-support/register +spec: + - out/**/*.test.js + - addons/**/out/*.test.js +watch-files: + - out/**/*.js + - addons/**/out/*.js +reporter: spec +color: true +check-leaks: true diff --git a/.vscode/settings.json b/.vscode/settings.json index f07ca545..ecea784c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "typescript.preferences.importModuleSpecifier": "non-relative", - "typescript.preferences.quoteStyle": "single" + "typescript.preferences.quoteStyle": "single", + "mochaExplorer.env": { + "NODE_PATH": "./out" + } } diff --git a/package.json b/package.json index 71a0f308..40de4017 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", + "test:dev": "NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", @@ -61,6 +62,7 @@ "nyc": "^15.1.0", "playwright": "^1.11.0", "source-map-loader": "^2.0.1", + "source-map-support": "^0.5.19", "ts-loader": "^9.1.2", "typescript": "^4.2.4", "utf8": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index 571f8a90..0d8ac14f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3909,7 +3909,7 @@ source-map-loader@^2.0.1: iconv-lite "^0.6.2" source-map-js "^0.6.2" -source-map-support@~0.5.19: +source-map-support@^0.5.19, source-map-support@~0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== From 8801926b1000c89bb1d50b4f1684e182140f0dd1 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 15:40:35 +0200 Subject: [PATCH 2/5] fix: `test:dev` is running on Windows --- package.json | 3 ++- yarn.lock | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 40de4017..43fb640e 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", - "test:dev": "NODE_PATH='./out' mocha", + "test:dev": "cross-env NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build", @@ -50,6 +50,7 @@ "@typescript-eslint/eslint-plugin": "^4.23.0", "@typescript-eslint/parser": "^4.23.0", "chai": "^4.3.4", + "cross-env": "^7.0.3", "deep-equal": "^2.0.5", "eslint": "^7.26.0", "express": "^4.17.1", diff --git a/yarn.lock b/yarn.lock index 0d8ac14f..cf92d8f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1329,7 +1329,14 @@ core-util-is@1.0.2, core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-env@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" + integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== + dependencies: + cross-spawn "^7.0.1" + +cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== From 7cda0017aa0f14d6e7ab8677e28f7a58ff2b89f5 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 15:53:43 +0200 Subject: [PATCH 3/5] fix: make Mocha Explorer working on Windows --- .env.test | 1 + .vscode/settings.json | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 .env.test diff --git a/.env.test b/.env.test new file mode 100644 index 00000000..78a9f930 --- /dev/null +++ b/.env.test @@ -0,0 +1 @@ +NODE_PATH=./out diff --git a/.vscode/settings.json b/.vscode/settings.json index ecea784c..7720b1ee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,5 @@ { "typescript.preferences.importModuleSpecifier": "non-relative", "typescript.preferences.quoteStyle": "single", - "mochaExplorer.env": { - "NODE_PATH": "./out" - } + "mochaExplorer.envPath": ".env.test" } From ac750596840ad3d43d788eb956ac48911abae623 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 16:56:40 +0200 Subject: [PATCH 4/5] refactor: rename file to a better name --- .env.test => .mocha.env | 0 .vscode/settings.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .env.test => .mocha.env (100%) diff --git a/.env.test b/.mocha.env similarity index 100% rename from .env.test rename to .mocha.env diff --git a/.vscode/settings.json b/.vscode/settings.json index 7720b1ee..9fa94d5f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { "typescript.preferences.importModuleSpecifier": "non-relative", "typescript.preferences.quoteStyle": "single", - "mochaExplorer.envPath": ".env.test" + "mochaExplorer.envPath": ".mocha.env" } From f41eea025ec68948ce1a92d1010ec2e3fce4c76f Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 31 Aug 2021 16:58:20 +0200 Subject: [PATCH 5/5] refactor: rename script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 43fb640e..29b6fd46 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000", "test-unit": "node ./bin/test.js", "test-unit-coverage": "node ./bin/test.js --coverage", - "test:dev": "cross-env NODE_PATH='./out' mocha", + "test-unit-dev": "cross-env NODE_PATH='./out' mocha", "build": "tsc -b ./tsconfig.all.json", "prepare": "npm run setup", "setup": "npm run build",