I am trying to run jest tests with gulp using gulp-jest. Installed these packages from npm:
"gulp-jest": "^4.0.3",
"jest-cli": "^25.3.0"
and provided the following configuration to jest:
"jest": {
"setupFilesAfterEnv": [
"<rootDir>/jest.setup.js"
],
"collectCoverage": true,
"coverageDirectory": "./test/unit-test-coverage",
"coverageReporters": [
"text",
"lcov"
]
}
I have written a basic method in my gulpfile.js, referred this link:
function runJsTests() {
process.env.NODE_ENV = 'test';
const __dirname = "Features/Components";
return gulp.src(__dirname).pipe(jest({
}));
}
However, I am getting the following error when I run the gulp task:
TypeError: Cannot read property 'runCLI' of undefined
I had the same trouble last friday, to resolve it, I finally had to downgrade version used of jest-cli :
"@types/jest": "24.9.0", "jest": "24.9.0", "ts-jest": "24.3.0 "jest-cli": "24.9.0", "jest-html-reporter": "2.5.0",
A bug known on new version of Jest-cli
-> think to remove all node_modules and package_lock.json!
Good luck ;)