[英]how to get Jest --watch to run on changes to JSON/YAML files?
[英]Jest watch not detecting changes to files
运行npm t -- --watch
未检测到对测试文件的更改。 如果我运行npm t
或npm run test:changed
(我的脚本仅用于运行通过jest -o
覆盖已更改文件的测试)一切正常,但是,不会检测到任何更改并且不会重新运行测试。
知道我做错了什么吗?
对于额外的上下文,我正在使用ts-jest
,这里是我的一些相关配置文件:
src/tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"moduleResolution": "node",
"outDir": "../dist",
"esModuleInterop": true,
"noImplicitAny": true,
"noEmitOnError": true,
"sourceMap": true,
"forceConsistentCasingInFileNames": true,
"lib": ["esnext", "esnext.asynciterable"],
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"include": ["./**/*.ts"],
"exclude": ["node_modules", "./**/*.test.ts"]
}
jest.config.ts
module.exports = {
globals: {
'ts-jest': {
tsConfig: 'src/tsconfig.json',
},
},
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx'],
roots: ['src'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
testMatch: ['**/*.test.(ts|js)'],
testEnvironment: 'node',
preset: 'ts-jest',
collectCoverageFrom: ['./src/**/*.ts', '!./src/migration/**', '!./src/tests/**'],
coverageDirectory: './',
coverageThreshold: {
global: {
statements: 60,
branches: 45,
functions: 35,
lines: 60,
},
},
};
事实证明,问题是我将 Jest 配置为使用./
作为覆盖位置(一切都是.gitignore
'd,所以谁在乎 ¯\\_(ツ)_/¯),这就造成了问题。 更多信息可以在 Jest repo上的相关问题上找到。
尝试npm jest --clearCache
如果您使用打字稿,有时 jests 缓存也会停止捕获更改,请尝试删除您的 dist 文件夹并重建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.