From 6b09d1467f907429e42633dcca8db6ff71f4283d Mon Sep 17 00:00:00 2001 From: Ronan Jouchet Date: Tue, 1 Jun 2021 23:37:04 -0400 Subject: [PATCH] More test:watch fixes & usability See https://github.com/nativefier/nativefier/pull/1204#issuecomment-852679403 --- app/webpack.config.js | 2 ++ package.json | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/webpack.config.js b/app/webpack.config.js index 243db04..582ef9b 100644 --- a/app/webpack.config.js +++ b/app/webpack.config.js @@ -1,5 +1,7 @@ const path = require('path'); +// Q: Why do you use webpack? +// A: https://github.com/nativefier/nativefier/commit/cde5c1e13bdc2739604cab04bac64eae0d719ed1 module.exports = { target: 'node', entry: './src/main.ts', diff --git a/package.json b/package.json index 433acc2..e447cd3 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "build-app": "cd app && webpack", "build-app-static": "ncp app/src/static/ app/lib/static/ && ncp app/dist/preload.js app/lib/preload.js && ncp app/dist/preload.js.map app/lib/preload.js.map", "build": "npm run clean && tsc --build . app && npm run build-app && npm run build-app-static", - "build:watch": "tsc --build . app --watch", + "build:watch": "npm run clean && tsc --build . app --watch", "changelog": "./.github/generate-changelog", "ci": "npm run lint && npm test", "clean": "rimraf lib/ app/lib/ app/dist/", @@ -47,7 +47,7 @@ "test:integration": "jest --testRegex '.*integration-test.js'", "test:manual": "npm run build && ./.github/manual-test", "test:unit": "jest", - "test:watch": "echo 'Remember to run npm run build:watch for the test watcher to work!' && jest --watch", + "test:watch": "echo 'Remember to run npm run build:watch for the test watcher to work!' && jest --watchAll --collectCoverage=false", "test:withlog": "LOGLEVEL=trace npm run test", "test": "jest --testRegex '[-.]test\\.js$'", "watch": "npx concurrently \"npm:*:watch\"" @@ -85,7 +85,7 @@ "webpack-cli": "^4.5.0" }, "jest_COMMENTS": { - "testPathIgnorePatterns": "See https://jestjs.io/docs/configuration#testpathignorepatterns-arraystring . We set it to 1. ignore coverage for deps, and 2. be sure we test the compiled JS, which is in `lib`, not `src`", + "testPathIgnorePatterns": "See https://jestjs.io/docs/configuration#testpathignorepatterns-arraystring . We set it to 1. ignore coverage for deps, and 2. be sure we test the compiled JS, which is in `lib`, not `src` or `dist`", "watchPathIgnorePatterns": "See https://jestjs.io/docs/configuration#watchpathignorepatterns-arraystring . We set it for `jest --watch` (a.k.a. `npm run test:watch`) to trigger only after `tsc --watch` (a.k.a. `npm run build:watch`) completes its incremental compilation. Else, jest will pick up immediately on changes in `src` when TSC is barely running, hence testing not-recompiled-yet code and being super confusing, as 1. your changes won't be taken during this first run, and 2. the *next* run (e.g. after a second 'Save' in your editor) will actually have the new code :D" }, "jest": { @@ -95,13 +95,18 @@ ], "testEnvironment": "node", "testPathIgnorePatterns": [ - "/node_modules/", + "/src.*", + "/node_modules.*", "/app/src.*", - "/src.*" + "/app/dist.*", + "/app/node_modules.*" ], "watchPathIgnorePatterns": [ + "/src.*", + "/tsconfig.json", "/app/src.*", - "/src.*" + "/app/dist.*", + "/app/tsconfig.json" ] }, "prettier": {