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
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'
}
});
};
$ 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]
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
};
| software | version(s)
| ---------------- | -------
| node | 11.6.0
| npm | 6.5.0-next.0
| yarn | 1.15.2
| Operating System | Windows 10
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?
Most helpful comment
One of the questions during
stryker initis:That's where you probably selected
typescript. Maybe this question should be reworded to:@Chowarmaan would that help you?
@simondel, agree?