运行 jest with grunt 未找到测试
No tests found on running jest with grunt
我正在尝试 运行 我的笑话 g运行t 任务,但在这样做时我在控制台中收到 No tests found 消息。这是相同的设置:
gruntfile.js 片段:
exec: {
jest: 'node node_modules/jest/bin/jest -u --config="test/unit/jest/jest.conf.json"'
}
jest.conf.json :
{
"testEnvironment": "jsdom",
"setupTestFrameworkScriptFile": "./enzyme.setup.js",
"testResultsProcessor": "jest-teamcity-reporter"
}
enzyme.setup.js :
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-15.4';
configure({ adapter: new Adapter() });
运行执行 g运行t 执行任务的控制台显示如下:
No tests found
In C:\Vishal\UI\Jest-Grunt\proj\test\unit\jest
3 files checked.
testMatch: .js?(x),**/?(*.)(spec|test).js?(x) - 0 matches
testPathIgnorePatterns: \node_modules\ - 3 matches
Pattern: - 0 matches
Done, without errors.
然而,令人惊讶的是,如果我不在 g运行t exec 任务中的 cli 中传递 jest 配置文件路径,而是在 package.json 文件中指定 jest 配置,那么它就可以工作。
不确定为什么会这样。
啊,在我的头上撞了一下。我注意到错误很可惜:
C:\My-User\UI\Jest-Grunt\proj\test\unit\jest
这清楚地解释了 JEST 试图在上面指定的文件夹内执行测试用例。但理想情况下 JEST 会调查 __tests__
。因此我必须自己指定根文件夹。使用包 json 不会发生这种情况。不过很奇怪!
这是我的更新笑话配置:
{
"testEnvironment": "jsdom",
"setupTestFrameworkScriptFile": "./enzyme.setup.js",
"testResultsProcessor": "jest-teamcity-reporter",
"coverageReporters": [
"teamcity", "lcov"
],
"roots": [
"../../../__tests__"
]
}
我正在尝试 运行 我的笑话 g运行t 任务,但在这样做时我在控制台中收到 No tests found 消息。这是相同的设置:
gruntfile.js 片段:
exec: {
jest: 'node node_modules/jest/bin/jest -u --config="test/unit/jest/jest.conf.json"'
}
jest.conf.json :
{
"testEnvironment": "jsdom",
"setupTestFrameworkScriptFile": "./enzyme.setup.js",
"testResultsProcessor": "jest-teamcity-reporter"
}
enzyme.setup.js :
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-15.4';
configure({ adapter: new Adapter() });
运行执行 g运行t 执行任务的控制台显示如下:
No tests found
In C:\Vishal\UI\Jest-Grunt\proj\test\unit\jest
3 files checked.
testMatch: .js?(x),**/?(*.)(spec|test).js?(x) - 0 matches
testPathIgnorePatterns: \node_modules\ - 3 matches
Pattern: - 0 matches
Done, without errors.
然而,令人惊讶的是,如果我不在 g运行t exec 任务中的 cli 中传递 jest 配置文件路径,而是在 package.json 文件中指定 jest 配置,那么它就可以工作。
不确定为什么会这样。
啊,在我的头上撞了一下。我注意到错误很可惜:
C:\My-User\UI\Jest-Grunt\proj\test\unit\jest
这清楚地解释了 JEST 试图在上面指定的文件夹内执行测试用例。但理想情况下 JEST 会调查 __tests__
。因此我必须自己指定根文件夹。使用包 json 不会发生这种情况。不过很奇怪!
这是我的更新笑话配置:
{
"testEnvironment": "jsdom",
"setupTestFrameworkScriptFile": "./enzyme.setup.js",
"testResultsProcessor": "jest-teamcity-reporter",
"coverageReporters": [
"teamcity", "lcov"
],
"roots": [
"../../../__tests__"
]
}