From a99521f04ec5791632a9e37ebb8b96633a4b8f55 Mon Sep 17 00:00:00 2001 From: StephanBijzitter Date: Wed, 15 Sep 2021 15:36:00 +0200 Subject: [PATCH] Change Jest configuration to also work on Windows Due to Windows file paths, jest wasn't able to find any test files and due to rm not being available on Windows, coverage could not be created. Updating the test matcher and replacing rm with rimraf (a node dependency) allows Windows to run this project properly when developing locally --- jest.config.js | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jest.config.js b/jest.config.js index c82b464..9ec5d10 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,7 @@ module.exports = { displayName: 'CspHtmlWebpackPlugin', roots: [''], - testMatch: ['/?(*.)jest.js'], + testMatch: ['**/*.jest.js'], testPathIgnorePatterns: ['/node_modules/'], clearMocks: true, }; diff --git a/package.json b/package.json index 96443eb..adaa0c2 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "jest": "jest --config=./jest.config.js plugin.jest.js", "jest:watch": "jest --watch --verbose=false --config=./jest.config.js plugin.jest.js", "jest:coverage:generate": "jest --coverage --config=./jest.config.js plugin.jest.js", - "jest:coverage:clean": "rm -rf ./coverage", + "jest:coverage:clean": "rimraf ./coverage", "jest:coverage:upload": "npx codecov", "jest:coverage": "npm run jest:coverage:clean && npm run jest:coverage:generate && npm run jest:coverage:upload", "test": "npm run eslint && npm run jest && npm run jest:coverage" @@ -48,6 +48,7 @@ "jest": "^26.6.3", "memory-fs": "^0.5.0", "prettier": "^2.2.1", + "rimraf": "^3.0.2", "webpack": "^5.10.1", "webpack-sources": "^2.2.0" }