Jest not finding any tests
See original GitHub issueDo you want to request a feature or report a bug?
Bug report.
What is the current behavior?
I’m converting one of my projects to TypeScript here: https://github.com/milesj/optimal Running yarn run jest
will not find and run any tests, no matter what variation of testMatch
and testRegex
that Itry. That being said, it’s correctly finding my jest.config.js
, as denoted when using --debug
, as seen below.
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "/var/folders/x1/q5gdh6d14h3fkxhgxx75k41h0000gn/T/jest_dx",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/",
"/lib/",
"/esm/"
],
"detectLeaks": false,
"forceCoverageMatch": [],
"globals": {
"__DEV__": true,
"ts-jest": {
"useBabelrc": true
}
},
"haste": {
"providesModuleNodeModules": []
},
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
".ts",
".tsx",
".js",
".jsx",
".json"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": [],
"name": "656565fb122fb27c21e0885f8d7856db",
"resetMocks": false,
"resetModules": false,
"restoreMocks": false,
"rootDir": "/Users/Miles/Sites/optimal",
"roots": [
"/Users/Miles/Sites/optimal/src",
"/Users/Miles/Sites/optimal/tests"
],
"runner": "jest-runner",
"setupFiles": [
"/Users/Miles/Sites/optimal/node_modules/regenerator-runtime/runtime.js"
],
"setupTestFrameworkScriptFile": null,
"snapshotSerializers": [],
"testEnvironment": "jest-environment-jsdom",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"testRunner": "/Users/Miles/Sites/optimal/node_modules/jest-jasmine2/build/index.js",
"testURL": "about:blank",
"timers": "real",
"transform": [
[
"^.+\\.jsx?$",
"/Users/Miles/Sites/optimal/node_modules/babel-jest/build/index.js"
],
[
"^.+\\.tsx?$",
"/Users/Miles/Sites/optimal/node_modules/ts-jest/index.js"
]
],
"transformIgnorePatterns": [
"/node_modules/"
],
"watchPathIgnorePatterns": []
}
],
"globalConfig": {
"bail": false,
"changedFilesWithAncestor": false,
"coverageDirectory": "/Users/Miles/Sites/optimal/coverage",
"coverageReporters": [
"lcov"
],
"detectLeaks": false,
"expand": false,
"globalSetup": null,
"globalTeardown": null,
"listTests": false,
"logHeapUsage": true,
"maxWorkers": 7,
"noStackTrace": false,
"nonFlagArgs": [],
"notify": false,
"notifyMode": "always",
"passWithNoTests": false,
"rootDir": "/Users/Miles/Sites/optimal",
"runTestsByPath": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": false,
"watch": false,
"watchman": true
},
"version": "22.4.2"
}
No tests found
No files found in /Users/Miles/Sites/optimal.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern: - 0 matches
What is the expected behavior?
It finds and runs my tests.
Please provide your exact Jest configuration
My Jest configuration is automatically built with Beemo, but looks like the following.
module.exports = {
"coverageDirectory": "./coverage",
"coveragePathIgnorePatterns": [
"/node_modules/",
"/lib/",
"/esm/"
],
"coverageReporters": [
"lcov"
],
"globals": {
"__DEV__": true,
"ts-jest": {
"useBabelrc": true
}
},
"moduleFileExtensions": [
".ts",
".tsx",
".js",
".jsx",
".json"
],
"rootDir": "/Users/Miles/Sites/optimal",
"roots": [
"./src",
"./tests"
],
"setupFiles": [],
"setupTestFrameworkScriptFile": null,
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"transform": {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "ts-jest"
},
"verbose": false
};
Run npx envinfo --preset jest
in your project directory and paste the
results here
System: OS: macOS High Sierra 10.13.3 CPU: x64 Intel® Core™ i7-4870HQ CPU @ 2.50GHz Binaries: Node: 9.8.0 Yarn: 1.5.1 npm: 5.1.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top GitHub Comments
Turns out the problem was that my
moduleFileExtensions
had a preceeding period. Perhaps Jest should check for that.This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.