我使用babel将文件从src转换为lib,当我尝试运行jest时,src/Template.js
和lib/Template.js
之间发生冲突
Using Jest CLI v0.9.0, jasmine2, babel-jest
Error: Failed to build DependencyGraph: @providesModule naming collision:
Duplicate module name: Template
Paths: src/Template.js collides with lib/Template.js
如何处理这种情况?有没有办法忽略其中一个目录?
在package.json中:
答案 0 :(得分:0)
问题是,jest默认搜索整个项目进行测试。 https://facebook.github.io/jest/docs/api.html#config-testpathdirs-array-string
package.json中的解决方案
"jest": {
"testPathDirs": [
"<rootDir>/__tests__", # Default is <rootDir>
"<rootDir>/lib" # Needed for automatic mocking to work
],
...
}