我在我的项目中编写了一些测试用例,但我无法调试它。我的项目结构如下 -
我在 vscode 中添加了 Jest Runner 包并将 jest.config.js 更改为 -
module.exports = {
roots: ['<rootDir>/src'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '**/src/**/?(*.)test.js?(x)',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFiles: ['<rootDir>/src/setupTests.ts'],
reporters: ['default', 'jest-junit'],
};
它没有用并且给了 - 一无所获
所以为了简单地测试一个文件,我在配置中给出了我的文件的相对路径 -
module.exports = {
roots: ['<rootDir>/src'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: 'src/components/ComponentA/filename.test.ts',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFiles: ['<rootDir>/src/setupTests.ts'],
reporters: ['default', 'jest-junit'],
};
这次我使用调试选项从文件进行调试
它得到了文件,但这次我得到了 - 未找到测试,以代码 1 退出 我还在 package.json 中添加了 --passWithNoTests 但仍然没有运气
请帮忙。