开玩笑手表不检测文件更改



运行npm t -- --watch不会检测到对测试文件的更改。如果我运行npm tnpm 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了,所以谁在̄\_(ツ)_/̄乎(,这造成了问题。有关 Jest 存储库相关问题的更多信息。

尝试npm jest --clearCache有时,如果您使用打字稿,jests 缓存也会停止捕获更改,请尝试删除 dist 文件夹并重建。

就我而言,配置已将测试设置为以--runInBand模式运行。如果删除它,手表就可以工作了。

最新更新