Stryker: npx stryker run with Jest does not work

Created on 18 Mar 2019  ยท  18Comments  ยท  Source: stryker-mutator/stryker

Summary

I was running the 0.34.x version previously in my project. I have since removed all traces to stryker, installed the new @stryker-mutator/core and proceeded to use the npx stryker init to install the dependencies and try to get stryker working in my environment with Jest and Yarn.

While my Jest tests all run normally, I get errors running stryker: npx stryker run stryker.conf.js. The error indicates that test files were not found.

11:49:51 (11656) WARN ChildProcessProxy Child process [pid 13664] exited unexpectedly with exit code 1 (without signal). Last part of stdout and stderr was:
No tests found, exiting with code 1
Run with --passWithNoTests to exit with code 0
No files found in C:Users\stevens\Development\TestScripts\Emulator.stryker-tmp\sandbox1586172.
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

Stryker config

module.exports = function(config) {
  config.set({
    mutator: "typescript",
    packageManager: "yarn",
    reporters: ["html", "clear-text", "progress"],
    testRunner: "jest",
    transpilers: ["typescript"],
    coverageAnalysis: "off",
    tsconfigFile: "tsconfig.json",
    mutate: [
        "src/**/*.ts",
        "!src/**/*.spec.ts"
    ],
    htmlReporter: {
        baseDir: 'docs/mutation'
    }

  });
};

Stryker environment

$ yarn list |grep stryker
โ”œโ”€ @stryker-mutator/[email protected]
โ”œโ”€ @stryker-mutator/[email protected]
โ”‚  โ”œโ”€ @stryker-mutator/api@^1.1.0
โ”‚  โ”œโ”€ @stryker-mutator/util@^1.1.0
โ”œโ”€ @stryker-mutator/[email protected]
โ”‚  โ”œโ”€ @stryker-mutator/api@^1.1.0
โ”‚  โ”œโ”€ @stryker-mutator/util@^1.1.0
โ”œโ”€ @stryker-mutator/[email protected]
โ”‚  โ”œโ”€ @stryker-mutator/api@^1.1.0
โ”œโ”€ @stryker-mutator/[email protected]
โ”‚  โ”œโ”€ @stryker-mutator/api@^1.1.0
โ”‚  โ”œโ”€ @stryker-mutator/util@^1.1.0
โ”œโ”€ @stryker-mutator/[email protected]

$ yarn list |grep jest
โ”œโ”€ @jest/[email protected]
โ”‚  โ”œโ”€ @jest/source-map@^24.3.0
โ”œโ”€ @jest/[email protected]
โ”‚  โ”œโ”€ @jest/console@^24.3.0
โ”‚  โ”œโ”€ @jest/reporters@^24.5.0
โ”‚  โ”œโ”€ @jest/test-result@^24.5.0
โ”‚  โ”œโ”€ @jest/transform@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-changed-files@^24.5.0
โ”‚  โ”œโ”€ jest-config@^24.5.0
โ”‚  โ”œโ”€ jest-haste-map@^24.5.0
โ”‚  โ”œโ”€ jest-message-util@^24.5.0
โ”‚  โ”œโ”€ jest-regex-util@^24.3.0
โ”‚  โ”œโ”€ jest-resolve-dependencies@^24.5.0
โ”‚  โ”œโ”€ jest-runner@^24.5.0
โ”‚  โ”œโ”€ jest-runtime@^24.5.0
โ”‚  โ”œโ”€ jest-snapshot@^24.5.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”‚  โ”œโ”€ jest-validate@^24.5.0
โ”‚  โ”œโ”€ jest-watcher@^24.5.0
โ”œโ”€ @jest/[email protected]
โ”‚  โ”œโ”€ @jest/fake-timers@^24.5.0
โ”‚  โ”œโ”€ @jest/transform@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ””โ”€ jest-mock@^24.5.0
โ”œโ”€ @jest/[email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-message-util@^24.5.0
โ”‚  โ””โ”€ jest-mock@^24.5.0
โ”œโ”€ @jest/[email protected]
โ”‚  โ”œโ”€ @jest/environment@^24.5.0
โ”‚  โ”œโ”€ @jest/test-result@^24.5.0
โ”‚  โ”œโ”€ @jest/transform@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-haste-map@^24.5.0
โ”‚  โ”œโ”€ jest-resolve@^24.5.0
โ”‚  โ”œโ”€ jest-runtime@^24.5.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”‚  โ”œโ”€ jest-worker@^24.4.0
โ”œโ”€ @jest/[email protected]
โ”œโ”€ @jest/[email protected]
โ”‚  โ”œโ”€ @jest/console@^24.3.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”œโ”€ @jest/[email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-haste-map@^24.5.0
โ”‚  โ”œโ”€ jest-regex-util@^24.3.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”œโ”€ @jest/[email protected]
โ”œโ”€ @stryker-mutator/[email protected]
โ”œโ”€ @types/[email protected]
โ”œโ”€ @types/[email protected]
โ”‚  โ””โ”€ @types/jest-diff@*
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/transform@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ babel-preset-jest@^24.3.0
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚  โ””โ”€ babel-plugin-jest-hoist@^24.3.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-get-type@^24.3.0
โ”‚  โ”œโ”€ jest-matcher-utils@^24.5.0
โ”‚  โ”œโ”€ jest-message-util@^24.5.0
โ”‚  โ””โ”€ jest-regex-util@^24.3.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/core@^24.5.0
โ”‚  โ”œโ”€ @jest/test-result@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-config@^24.5.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”‚  โ”œโ”€ jest-validate@^24.5.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ babel-jest@^24.5.0
โ”‚  โ”œโ”€ jest-environment-jsdom@^24.5.0
โ”‚  โ”œโ”€ jest-environment-node@^24.5.0
โ”‚  โ”œโ”€ jest-get-type@^24.3.0
โ”‚  โ”œโ”€ jest-jasmine2@^24.5.0
โ”‚  โ”œโ”€ jest-regex-util@^24.3.0
โ”‚  โ”œโ”€ jest-resolve@^24.5.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”‚  โ”œโ”€ jest-validate@^24.5.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ jest-get-type@^24.3.0
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-get-type@^24.3.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/environment@^24.5.0
โ”‚  โ”œโ”€ @jest/fake-timers@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-mock@^24.5.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/environment@^24.5.0
โ”‚  โ”œโ”€ @jest/fake-timers@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-mock@^24.5.0
โ”‚  โ””โ”€ jest-util@^24.5.0
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-serializer@^24.4.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”‚  โ”œโ”€ jest-worker@^24.4.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/environment@^24.5.0
โ”‚  โ”œโ”€ @jest/test-result@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-each@^24.5.0
โ”‚  โ”œโ”€ jest-matcher-utils@^24.5.0
โ”‚  โ”œโ”€ jest-message-util@^24.5.0
โ”‚  โ”œโ”€ jest-runtime@^24.5.0
โ”‚  โ”œโ”€ jest-snapshot@^24.5.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ jest-diff@^24.5.0
โ”‚  โ”œโ”€ jest-get-type@^24.3.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/test-result@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”œโ”€ [email protected]
โ”‚  โ””โ”€ @jest/types@^24.5.0
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-regex-util@^24.3.0
โ”‚  โ””โ”€ jest-snapshot@^24.5.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-pnp-resolver@^1.2.1
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/console@^24.3.0
โ”‚  โ”œโ”€ @jest/environment@^24.5.0
โ”‚  โ”œโ”€ @jest/test-result@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-config@^24.5.0
โ”‚  โ”œโ”€ jest-docblock@^24.3.0
โ”‚  โ”œโ”€ jest-haste-map@^24.5.0
โ”‚  โ”œโ”€ jest-jasmine2@^24.5.0
โ”‚  โ”œโ”€ jest-leak-detector@^24.5.0
โ”‚  โ”œโ”€ jest-message-util@^24.5.0
โ”‚  โ”œโ”€ jest-resolve@^24.5.0
โ”‚  โ”œโ”€ jest-runtime@^24.5.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”‚  โ”œโ”€ jest-worker@^24.4.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/console@^24.3.0
โ”‚  โ”œโ”€ @jest/environment@^24.5.0
โ”‚  โ”œโ”€ @jest/source-map@^24.3.0
โ”‚  โ”œโ”€ @jest/transform@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-config@^24.5.0
โ”‚  โ”œโ”€ jest-haste-map@^24.5.0
โ”‚  โ”œโ”€ jest-message-util@^24.5.0
โ”‚  โ”œโ”€ jest-mock@^24.5.0
โ”‚  โ”œโ”€ jest-regex-util@^24.3.0
โ”‚  โ”œโ”€ jest-resolve@^24.5.0
โ”‚  โ”œโ”€ jest-snapshot@^24.5.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”‚  โ”œโ”€ jest-validate@^24.5.0
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-diff@^24.5.0
โ”‚  โ”œโ”€ jest-matcher-utils@^24.5.0
โ”‚  โ”œโ”€ jest-message-util@^24.5.0
โ”‚  โ”œโ”€ jest-resolve@^24.5.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/console@^24.3.0
โ”‚  โ”œโ”€ @jest/fake-timers@^24.5.0
โ”‚  โ”œโ”€ @jest/source-map@^24.3.0
โ”‚  โ”œโ”€ @jest/test-result@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-get-type@^24.3.0
โ”œโ”€ [email protected]
โ”‚  โ”œโ”€ @jest/test-result@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”‚  โ”œโ”€ jest-util@^24.5.0
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”‚  โ””โ”€ jest-cli@^24.5.0
โ”‚  โ”œโ”€ @jest/types@^24.5.0
โ”œโ”€ [email protected]

Test runner environment

jest --config jest.config.js --no-cache

module.exports = {
    // Indicates whether the coverage information should be collected while executing the test
    collectCoverage: true,

    // An array of glob patterns indicating a set of files for which coverage information should be collected
    collectCoverageFrom: [
        '<rootDir>/src/**/*.ts',
        '!<rootDir>/src/**/*.mock.ts',
        '!<rootDir>/src/**/*.module.ts',
        '!<rootDir>/src/**/*.spec.ts',
        '!<rootDir>/src/**/*.test.ts',
        '!<rootDir>/src/**/*.d.ts',
        '!<rootDir>/src/**/__*__/*',
    ],
    // The directory where Jest should output its coverage files
    coverageDirectory: "<rootDir>/docs",

    // An array of regexp pattern strings used to skip coverage collection
    coveragePathIgnorePatterns: [
        "\\\\node_modules\\\\"
    ],

    // A list of reporter names that Jest uses when writing coverage reports
    coverageReporters: [
        "lcov",
        "clover"
    ],

    // Make calling deprecated APIs throw helpful error messages
    errorOnDeprecated: true,

    // A set of global variables that need to be available in all test environments
    globals: {
        "ts-jest": {
            "diagnostics": false,
            "tsConfig": "tsconfig.json"
        }
    },

    // An array of file extensions your modules use
    moduleFileExtensions: [
        "ts",
        "tsx",
        "js"
    ],

    // A list of paths to directories that Jest should use to search for files in
    roots: [
       "<rootDir>/src"
    ],

    // The test environment that will be used for testing
    testEnvironment: "node",

    // The glob patterns Jest uses to detect test files
    testMatch: [
        "**/*.spec.ts"
    ],

    // A map from regular expressions to paths to transformers
    transform: {
        "^.+\\.(ts|tsx)$": "ts-jest"
    },

    // Indicates whether each individual test should be reported during the run
    verbose: false
};

Your Environment

| software | version(s)
| ---------------- | -------
| node | 11.6.0
| npm | 6.5.0-next.0
| yarn | 1.15.2
| Operating System | Windows 10

Add stryker.log

stryker.log

Most helpful comment

One of the questions during stryker init is:

[optional] What kind transformations should be applied to your code?

That's where you probably selected typescript. Maybe this question should be reworded to:

[optional] What kind transformations should Stryker apply code? If your test runner transpiles your code, select none here,

@Chowarmaan would that help you?

@simondel, agree?

All 18 comments

Hi @Chowarmaan thanks for opening this issue.

Could you please remove the transpilers part of your stryker.conf.js file and try again? Since your using Jest, it will take care of the typescript transpiling. Stryker doesn't need to do that for you.

@nicojs That corrected my issue. I guess I still flagged the additional transpiler option during the stryker init as I did not enter that myself. It has allowed my tests to run again.

One of the questions during stryker init is:

[optional] What kind transformations should be applied to your code?

That's where you probably selected typescript. Maybe this question should be reworded to:

[optional] What kind transformations should Stryker apply code? If your test runner transpiles your code, select none here,

@Chowarmaan would that help you?

@simondel, agree?

I think that might of, but maybe still not in my case unless the note is clearer for Jest somehow as I would still have expected to need to transpile the code for things to work. I did not think to deep about it, or really understand what you might be pointing at, even though webpack and others are there (if it is the area I am thinking of).

Hmmm maybe we should give a warning from the JestRunner. Something like: "WARN: You configured the "typescript" transpiler. This is probably not needed since Jest normally takes care of that. Set jest.ignoreTranspilerWarning to true to ignore this warning"

Would that help you @Chowarmaan ?

That I would have picked up. I actually just ran your same init over an Angular CLI project, and the caution about needing a transpiler (I did not) made me think as well. I think for the more beginner users like myself with Stryker, and some of the ecosystem of these tools, who are working with Typescript and trying to make the best code possible, these clearer examples would help.

On a side note, love the tool as Mutation testing has certainly helped me improve and find some subtle bugs.

@nicojs I think we should improve the message using Stryker init and we should warn the user when they specify transpilers with Jest. I'm fine with leaving this warning on instead of introducing another config setting.

@simondel @nicojs
Faced with same issue
Looks like it is jest issue https://github.com/facebook/jest/issues/8520
Stryker creates temp folder with name .stryker-tmp

D:\My\Dev\node-package-starter>npx jest --runInBand --testMatch "<rootDir>/.stryker-tmp/sandbox6795124/src/**/*.spec.ts"
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In D:\My\Dev\node-package-starter
  11 files checked.
  testMatch: D:/My/Dev/node-package-starter\.stryker-tmp/sandbox6795124/src/**/*.spec.ts - 0 matches
  testPathIgnorePatterns: \\node_modules\\ - 11 matches
  testRegex:  - 0 matches
Pattern:  - 0 matches

After renaming temp folder to stryker-tmp without dot

D:\My\Dev\node-package-starter>npx jest --runInBand --testMatch "<rootDir>/stryker-tmp/sandbox6795124/src/**/*.spec.ts"
 PASS  stryker-tmp/sandbox6795124/src/index.spec.ts
  โˆš smoke (6ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        2.204s, estimated 3s
Ran all test suites.

Can we configure name of the temp folder?

So what about it?

Suggested workaround in facebook/jest#8520 replace <rootDir> by real absolute path with / and not use \.

Can't help in this case because <rootDir> is dynamic when I run stryker run.

For me I hit this issue too when using ts-jest. Removing the config-part transpilers: ["typescript"], from the stryker.conf.js helped.

As there already are none-options to select, how about just giving the option to not have transpilers being filled? Would reduce this to a RTFM-issue the next time ;) (at least regarding this configuration issue).

I have the same or similar issue. I created a new project with vue-cli with following settings:

package.json

{
  "name": "stryker",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:unit": "vue-cli-service test:unit",
    "stryker": "stryker run"
  },
  "dependencies": {
    "core-js": "^3.4.4",
    "cross-env": "^7.0.0",
    "vue": "^2.6.10",
    "vue-class-component": "^7.0.2",
    "vue-property-decorator": "^8.3.0"
  },
  "devDependencies": {
    "@stryker-mutator/core": "^2.5.0",
    "@stryker-mutator/html-reporter": "^2.5.0",
    "@stryker-mutator/jest-runner": "^2.5.0",
    "@stryker-mutator/typescript": "^2.5.0",
    "@stryker-mutator/vue-mutator": "^2.5.0",
    "@types/jest": "^24.0.19",
    "@vue/cli-plugin-babel": "^4.1.0",
    "@vue/cli-plugin-typescript": "^4.1.0",
    "@vue/cli-plugin-unit-jest": "^4.1.0",
    "@vue/cli-service": "^4.1.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "typescript": "~3.5.3",
    "vue-template-compiler": "^2.6.10"
  }
}

sryker.conf.js

module.exports = function(config) {
  config.set({
    tempDir: "xxxs",
    mutate: ["src/**/*.vue"],
    mutator: "vue",
    testRunner: "jest",
    logLevel: "all",
    reporters: ["progress", "clear-text", "html"],
    coverageAnalysis: "off"
  });
};

output

11:56:22 (98231) TRACE JestPromiseTestAdapter Invoking Jest with config {"moduleFileExtensions":["js","vue"],"moduleNameMapper":{"^@/(.*)$":"<rootDir>/src/$1"},"testEnvironment":"jsdom","testMatch":["**/tests/unit/**"],"transform":{"^.+\\.(js|jsx)?$":"babel-jest",".*\\.(vue)$":"vue-jest"},"verbose":false,"collectCoverage":false,"bail":false,"notify":false,"rootDir":"/Users/user/code/stryker/stryker/xxxs/sandbox935509","reporters":[]}
11:56:22 (98231) TRACE JestPromiseTestAdapter Only running tests related to /Users/user/code/stryker/stryker/xxxs/sandbox935509/src/App.vue
11:56:23 (98213) TRACE ChildProcessProxy No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
No files found in /Users/user/code/stryker/stryker/xxxs/sandbox935509.
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: /Users/user/code/stryker/stryker/xxxs/sandbox935509/src/App.vue - 0 matches

Stryker does not find any tests within the sandbox. But when I copy the sandboxes and ran the tests manually, then they will fail. It means that the mutation itself works... Any ideas? Thx

Maybe try "files" option or check if files aren't excluded in .gitignore

No, did not work :(

Is this issue still present?

The initial errors were corrected via my configuration and removing the transpilers. Not sure if this issue still being open is for the help/error/init messaging or another reason.

so i believe it can be closed?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anthony-telljohann picture anthony-telljohann  ยท  19Comments

VincentLanglet picture VincentLanglet  ยท  31Comments

jeznag picture jeznag  ยท  17Comments

nosideeffects picture nosideeffects  ยท  32Comments

nicojs picture nicojs  ยท  17Comments