Jest: 'No tests found' when directory has a '-'

Created on 1 Sep 2016  路  8Comments  路  Source: facebook/jest

I am using [email protected], when my directory that include my git repo has a '-', I see the following behavior:

No tests found
74 files checked.
testPathDirs: - 0 matches
testRegex: /tests/.*.(ts|tsx|js)$ - 1 match
testPathIgnorePatterns: \node_modules\ - 74 matches

if I rename the repo directory not to have a dash, this will work fine and I can see a test. I am assuming this not an expected behavior.

Most helpful comment

I'm actually giving up on jest. Mocha "just worked" (by following the docs). :-\

All 8 comments

Can you post your configuration?

"jest": {
"scriptPreprocessor": "./preprocessor.js",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"testRegex": "/tests/.*.(ts|tsx|js)$",
"verbose": true,
"collectCoverage": true
}

Duplicate: 1568 1551

for people finding this issue, would it be possible to close the duplicates, noting which issue they are a duplicate of, so that only the issue where actual work towards fixing it happens stays open?

This isn't resolved. :-\

my config:

const {defaults} = require('jest-config');

const wd = process.cwd().replace(/\//g, '\\/');

console.log(wd);

module.exports = {
  // moduleDirectories: ["node_modules", ".", "src", "tests"],
  moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],

  projects: [
    {
      displayName: 'End to End',

      preset: "jest-puppeteer",

      globalSetup: "<rootDir>/tests/support/acceptance/setup.js",
      globalTeardown: "<rootDir>/tests/support/acceptance/teardown.js",
      testEnvironment: "<rootDir>/tests/support/acceptance/puppeteer-environment.js",

      testRegex: `${wd}/(.+)\\.e2e\\.ts`,
    },
    {
      displayName: 'Unit and Integration',

      setupTestFrameworkScriptFile: '<rootDir>/tests/support/setup.js',

      testRegex: "(.+)test\\.ts"
    }
  ],
  transform: {
   "^.+\\.(t|j)sx?$": "ts-jest"
  },
  globals: {
    "ts-jest": {
      tsConfigFile: "tsconfig.jest.json"
    }
  },
}

output

$ yarn test --verbose
yarn run v1.6.0
$ ./node_modules/.bin/jest --config ./jest.config.js --no-cache --verbose
\/home\/me\/Development\/NullVoxPopuli\/react-vs-ember\/testing\/react
No tests found
In /home/me/Development/NullVoxPopuli/react-vs-ember/testing/react
  182 files checked.
  testMatch:  - 182 matches
  testPathIgnorePatterns: /node_modules/ - 182 matches
  testRegex: \/home\/me\/Development\/NullVoxPopuli\/react-vs-ember\/testing\/react/(.+)\.e2e\.ts - 0 matches
In /home/me/Development/NullVoxPopuli/react-vs-ember/testing/react
  182 files checked.
  testMatch:  - 182 matches
  testPathIgnorePatterns: /node_modules/ - 182 matches
  testRegex: (.+)test\.ts - 0 matches
Pattern:  - 0 matches
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

given that all three issues are closed, you probably want to file that as a new issue.

I'm actually giving up on jest. Mocha "just worked" (by following the docs). :-\

That's entirely your call, but I'd still recommend filing your issue as a new issue so that devs are notified of it, and people who aren't you (but also run into this problem) may eventually get the fix they need still anyway.

Was this page helpful?
0 / 5 - 0 ratings