vendredi 14 août 2020

Jest - No tests found

I have specific situation. I have something like common module that define common behaviour of all integrations and all integrations is using that as a library. In that common module, I have configuration of jest and set of tests.

Everything works OK in case that common module is linked (npm link) to integration. But when this this common module is installed directly from npm, jest is not able to find any tests. I suppose, there are some files ignored, but I was not abe to find any configuration that would solve this situation.

Final configuration from debug mode looks like this:

{
  "configs": [
    {
      "automock": false,
      "cache": true,
      "cacheDirectory": "/private/var/folders/mv/v_zhxfq113qf8d6vsf4ldwq80000gn/T/jest_dx",
      "clearMocks": false,
      "coveragePathIgnorePatterns": [
        "/node_modules/"
      ],
      "cwd": "<path>/Workspace/integration/my_integration",
      "detectLeaks": false,
      "detectOpenHandles": false,
      "errorOnDeprecated": false,
      "extraGlobals": [],
      "forceCoverageMatch": [],
      "globals": {},
      "haste": {
        "computeSha1": false,
        "throwOnModuleCollision": false
      },
      "moduleDirectories": [
        "node_modules"
      ],
      "moduleFileExtensions": [
        "js",
        "json",
        "jsx",
        "ts",
        "tsx",
        "node"
      ],
      "moduleNameMapper": [],
      "modulePathIgnorePatterns": [],
      "name": "24eedccdafdba030f3d9209ab1064c8e",
      "prettierPath": "prettier",
      "resetMocks": false,
      "resetModules": false,
      "restoreMocks": false,
      "rootDir": "<path>/Workspace/integration/my_integration/node_modules/common_module/tests/api",
      "roots": [
        "<path>/Workspace/integration/my_integration/node_modules/common_module/tests/api"
      ],
      "runner": "jest-runner",
      "setupFiles": [],
      "setupFilesAfterEnv": [],
      "skipFilter": false,
      "slowTestThreshold": 5,
      "snapshotSerializers": [],
      "testEnvironment": "<path>/Workspace/integration/my_integration/node_modules/jest-environment-node/build/index.js",
      "testEnvironmentOptions": {},
      "testLocationInResults": false,
      "testMatch": [
        "**/__tests__/**/*.[jt]s?(x)",
        "**/?(*.)+(spec|test).[tj]s?(x)"
      ],
      "testPathIgnorePatterns": [
        "/node_modules/"
      ],
      "testRegex": [],
      "testRunner": "<path>/Workspace/integration/my_integration/node_modules/jest-jasmine2/build/index.js",
      "testURL": "http://localhost",
      "timers": "real",
      "transform": [],
      "transformIgnorePatterns": [
        "/node_modules/",
        "\\.pnp\\.[^\\/]+$"
      ],
      "watchPathIgnorePatterns": []
    }
  ],
  "globalConfig": {
    "bail": 0,
    "changedFilesWithAncestor": false,
    "collectCoverage": false,
    "collectCoverageFrom": [],
    "coverageDirectory": "<path>/Workspace/integration/my_integration/node_modules/common_module/coverage",
    "coverageProvider": "babel",
    "coverageReporters": [
      "json",
      "text",
      "lcov",
      "clover"
    ],
    "detectLeaks": false,
    "detectOpenHandles": false,
    "errorOnDeprecated": false,
    "expand": false,
    "findRelatedTests": false,
    "forceExit": false,
    "json": false,
    "lastCommit": false,
    "listTests": false,
    "logHeapUsage": false,
    "maxConcurrency": 5,
    "maxWorkers": 7,
    "noStackTrace": false,
    "nonFlagArgs": [],
    "notify": false,
    "notifyMode": "failure-change",
    "onlyChanged": false,
    "onlyFailures": false,
    "passWithNoTests": false,
    "projects": [],
    "rootDir": "<path>/Workspace/integration/my_integration/node_modules/common_module/tests/api",
    "runTestsByPath": false,
    "skipFilter": false,
    "testFailureExitCode": 1,
    "testPathPattern": "",
    "testSequencer": "<path>/Workspace/integration/my_integration/node_modules/@jest/test-sequencer/build/index.js",
    "updateSnapshot": "new",
    "useStderr": false,
    "verbose": true,
    "watch": false,
    "watchAll": false,
    "watchman": true
  },
  "version": "26.4.0"
}

All tests are defined on path <path>/Workspace/integration/my_integration/node_modules/common_module/tests/api named as e.g. something.test.js.

Console will show allways:

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
No files found in <path>/Workspace/integration/my_integration/node_modules/common_module/tests/api.
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
npm ERR! Test failed.  See above for more details.

Aucun commentaire:

Enregistrer un commentaire