stryker-mutator / stryker-cli Goto Github PK
View Code? Open in Web Editor NEWThe command-line interface for Stryker, the JavaScript mutation testing framework
Home Page: http://stryker-mutator.github.io
License: Apache License 2.0
The command-line interface for Stryker, the JavaScript mutation testing framework
Home Page: http://stryker-mutator.github.io
License: Apache License 2.0
So having helped develop, I didn't encounter any problems when running stryker init
locally. However, today I installed styker-cli
globally using npm and encountered the following issue.
> stryker init
env: node\r: No such file or directory
Continuing thread from stryker-mutator/stryker-js#917 (comment)
When initializing Stryker with stryker init
on a new Angular project, the Stryker CLI installs the dev package 'stryker-html-reporter' instead of the dev package '@stryker-mutator/html-reporter' (as indicated by in the Angular handbook). This causes stryker run
to fail when run directly after stryker init
with the following error message:
12:22:54 (13034) INFO ConfigReader Using stryker.conf.js in the current working directory.
12:22:54 (13034) WARN PluginLoader Error during loading "~/project/node_modules/@stryker-mutator/karma-runner" plugin:
Cannot find module 'karma'
12:22:54 (13034) WARN PluginLoader Error during loading "~/project/node_modules/@stryker-mutator/typescript" plugin:
Cannot find module 'typescript'
12:22:54 (13034) ERROR StrykerCli an error occurred { Error: Could not inject "InputFileResolver". Inner error: Could not inject "BroadcastReporter". Inner error: Cannot load Reporter plugin "html". Did you forget to install it? Loaded Reporter plugins were: clear-text, progress, progress-append-only, dots, event-recorder, dashboard
at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:35:19)
at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:95:22)
at Stryker.<anonymous> (~/project/node_modules/@stryker-mutator/core/src/Stryker.js:62:60)
at step (~/project/node_modules/tslib/tslib.js:133:27)
at Object.next (~/project/node_modules/tslib/tslib.js:114:57)
at fulfilled (~/project/node_modules/tslib/tslib.js:104:62)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
innerError:
{ Error: Could not inject "BroadcastReporter". Inner error: Cannot load Reporter plugin "html". Did you forget to install it? Loaded Reporter plugins were: clear-text, progress, progress-append-only, dots, event-recorder, dashboard
at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:35:19)
at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:95:22)
at ClassProvider.result (~/project/node_modules/typed-inject/src/InjectorImpl.js:173:21)
at ClassProvider.resolveInternal (~/project/node_modules/typed-inject/src/InjectorImpl.js:131:36)
at ClassProvider.resolve (~/project/node_modules/typed-inject/src/InjectorImpl.js:70:21)
at ClassProvider.resolve (~/project/node_modules/typed-inject/src/InjectorImpl.js:103:22)
at FactoryProvider.resolveInternal (~/project/node_modules/typed-inject/src/InjectorImpl.js:142:32)
at FactoryProvider.resolve (~/project/node_modules/typed-inject/src/InjectorImpl.js:70:21)
at FactoryProvider.resolve (~/project/node_modules/typed-inject/src/InjectorImpl.js:103:22)
at ClassProvider.resolveInternal (~/project/node_modules/typed-inject/src/InjectorImpl.js:142:32)
innerError:
Error: Cannot load Reporter plugin "html". Did you forget to install it? Loaded Reporter plugins were: clear-text, progress, progress-append-only, dots, event-recorder, dashboard
at PluginLoader.resolve (~/project/node_modules/@stryker-mutator/core/src/di/PluginLoader.js:31:23)
at PluginCreator.create (~/project/node_modules/@stryker-mutator/core/src/di/PluginCreator.js:11:42)
at BroadcastReporter.createReporter (~/project/node_modules/@stryker-mutator/core/src/reporters/BroadcastReporter.js:23:59)
at ~/project/node_modules/@stryker-mutator/core/src/reporters/BroadcastReporter.js:15:79
at Array.forEach (<anonymous>)
at new BroadcastReporter (~/project/node_modules/@stryker-mutator/core/src/reporters/BroadcastReporter.js:15:32)
at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:32:20)
at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:95:22)
at ClassProvider.result (~/project/node_modules/typed-inject/src/InjectorImpl.js:173:21)
at ClassProvider.resolveInternal (~/project/node_modules/typed-inject/src/InjectorImpl.js:131:36) } }
12:22:54 (13034) INFO StrykerCli Trouble figuring out what went wrong? Try `npx stryker run --fileLogLevel trace --logLevel debug` to get some more info.
ng new <project name>
stryker init
stryker run
Angular-cli: 7.3.4
Stryker-cli: 1.0.3
// This config was generated using a preset.
// Please see the handbook for more information: https://github.com/stryker-mutator/stryker-handbook/blob/master/stryker/guides/angular.md#angular
module.exports = function(config) {
config.set({
mutate: [
"src/**/*.ts",
"!src/**/*.spec.ts",
"!src/test.ts",
"!src/environments/*.ts"
],
mutator: "typescript",
testRunner: "karma",
karma: {
configFile: "src/karma.conf.js",
projectType: "angular-cli",
config: {
browsers: ["ChromeHeadless"]
}
},
reporters: ["progress", "clear-text", "html"],
maxConcurrentTestRunners: 2, // Recommended to use about half of your available cores when running stryker with angular.
coverageAnalysis: "off"
});
};
@stryker-mutator/html-reporter' html reporter is installed by Stryker-cli as per Angular handbook
stryker-html-reporter dev package is installed.
Stryker CLI is using npms.io in order to search for packages which is not supported by my company's firewall. I also suspect that multiple companies don't whitelist npms.io since it's not very common like npmjs.
Is it possible to have an option to select a different npm search that uses npmjs? Like a fallback?
data-registry-ers-load ufen$ stryker init
? Are you using one of these frameworks? Then select a preset configuration. None/other
11:25:08 (73629) ERROR StrykerInitializer Unable to reach npms.io (for query /v2/search?q=keywords:@stryker-mutator/test-runner-plugin). Please check your internet connection. Error: ETIMEDOUT (connect) Error: connect ETIMEDOUT 172.67.169.48:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14)
Unable to select a test runner. You will need to configure it manually.
Currently the description of this repo is:
The command line interface for Stryker (Work in progress!)
However, the CLI is now functional for stryker's installation, and for sending commands to stryker e.g. init
. I think it's time to promote the repo from work-in-progress to something more appropriate. Which I'm sadly not able to do.
So, I propose something along the same lines as the stryker-api.
The API for Stryker, the JavaScript mutation testing framework
For example:
The command line interface for Stryker, the JavaScript mutation testing framework
Lasty, as Stryker is now the 'The extendable JavaScript mutation testing framework.' I think we should also add extendable to both of those description. And for uniformity, I propose to remove the dot (.) at the end of the description in the main stryker repo.
Convert Stryker Quickstart to a command line interface command.
I have a public repo here that is a simple ExpressJS NodeJs project in TypeScript which uses Jest for unit tests.
When I run npx stryker run --fileLogLevel trace --logLevel debug
though I get this output and error:
16:23:03 (41154) INFO ConfigReader Using stryker.conf.js in the current working directory.
16:23:03 (41154) DEBUG ConfigReader Loading config stryker.conf.js
16:23:03 (41154) DEBUG PluginLoader Loading stryker-* from /Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules
16:23:03 (41154) DEBUG PluginLoader Expression stryker-* not resulted in plugins to load
16:23:03 (41154) DEBUG PluginLoader Loading plugins /Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/stryker/src/reporters/index.js
16:23:03 (41154) DEBUG PluginLoader Loading plugins /Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/stryker/src/mutators/index.js
16:23:03 (41154) DEBUG BroadcastReporter Broadcasting to reporters ["clear-text","progress"]
16:23:03 (41154) INFO InputFileResolver Found 3 of 11 file(s) to be mutated.
16:23:03 (41154) DEBUG InputFileResolver All input files: [
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/jest.config.js",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/package-lock.json",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/package.json",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/src/app.ts",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/src/sum.test.ts",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/src/sum.ts",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/stryker.conf.js",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/tsconfig.json",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/.gitignore",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/LICENSE",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/README.md"
]
16:23:03 (41154) DEBUG InputFileResolver Files to mutate: [
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/src/app.ts",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/src/sum.test.ts",
"/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/src/sum.ts"
]
16:23:03 (41154) WARN TestFrameworkOrchestrator Missing config settings `testFramework`. Set `coverageAnalysis` option explicitly to "off" to ignore this warning.
16:23:03 (41154) ERROR StrykerCli an error occurred Exception [Error]: Could not inject "InitialTestExecutor". Inner error: Could not inject "TranspilerFacade". Inner error: Cannot load Transpiler plugin "typescript". In fact, no Transpiler plugins were loaded. Did you forget to install it?
at ClassProvider.injectClass (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:35:19)
at ClassProvider.injectClass (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:95:22)
at Stryker.<anonymous> (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/stryker/src/Stryker.js:75:30)
at step (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/tslib/tslib.js:133:27)
at Object.next (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/tslib/tslib.js:114:57)
at fulfilled (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/tslib/tslib.js:104:62) {
innerError: Exception [Error]: Could not inject "TranspilerFacade". Inner error: Cannot load Transpiler plugin "typescript". In fact, no Transpiler plugins were loaded. Did you forget to install it?
at ClassProvider.injectClass (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:35:19)
at ClassProvider.injectClass (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:95:22)
at ClassProvider.result (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:173:21)
at ClassProvider.resolveInternal (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:131:36)
at /Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:56:33
at Array.map (<anonymous>)
at ClassProvider.resolveParametersToInject (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:49:23)
at ClassProvider.injectClass (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:31:31)
at ClassProvider.injectClass (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:95:22)
at Stryker.<anonymous> (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/stryker/src/Stryker.js:75:30) {
innerError: Error: Cannot load Transpiler plugin "typescript". In fact, no Transpiler plugins were loaded. Did you forget to install it?
at PluginLoader.resolve (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/stryker/src/di/PluginLoader.js:40:19)
at PluginCreator.create (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/stryker/src/di/PluginCreator.js:11:42)
at /Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/stryker/src/transpiler/TranspilerFacade.js:17:103
at Array.map (<anonymous>)
at new TranspilerFacade (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/stryker/src/transpiler/TranspilerFacade.js:17:14)
at ClassProvider.injectClass (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:32:20)
at ClassProvider.injectClass (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:95:22)
at ClassProvider.result (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:173:21)
at ClassProvider.resolveInternal (/Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:131:36)
at /Users/jim/Git-Projects/mtdd-typescript-nodejs-example/node_modules/typed-inject/src/InjectorImpl.js:56:33
}
}
I thought I should have all the necessary things installed already since I followed all the documentation and have these three striker dev dependencies installed in my package.json file:
{
"name": "mtdd-typescript-nodejs-example",
"version": "1.0.0",
"description": "from the live stream!",
"main": "index.js",
"scripts": {
"start": "node dist/app.js",
"build": "tsc",
"test": "jest",
"test:cov": "jest --coverage",
"mtdd": "stryker run"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/express": "^4.17.17",
"express": "^4.18.2"
},
"devDependencies": {
"@stryker-mutator/typescript": "^4.0.0",
"@types/jest": "^29.5.3",
"jest": "^29.6.2",
"stryker": "^0.35.1",
"stryker-api": "^0.24.1",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
}
}
Am I doing something wrong here? Anyone see how I can get stryker running properly in this project? Thanks!
PS. I am using node v18.17.0
The CLI is only available from the index.js file. A binary (stryker) should be build before releasing to npm
Nicojs told me that the stryker install can be found more easily by not looking in the folder but by using require('stryker') (see if it exists) and require.resolve('stryker') (resolve the path). This would be nice functionality since then you no longer have to be at the root of your folder to execute the stryker command.
Originally reported by @mjh5153
When I go to run the command Stryker run, I keep getting prompted that Stryker is currently not installed. I can see that Stryker and Stryker-api are installed via node modules and package.json.
When the stryker-cli can't run Stryker, it checks against the error Cannot find module '@stryker-mutator/core'
using indexOf
in the entire error.
In my case (Node v14.16.0) the entire error is: Error: Cannot find module '@stryker-mutator/core/package.json' from 'C:\git\myrepo'
So I believe a check for Cannot find module '@stryker-mutator/core
without a single quote at the end would be more suited in this case.
I really like the ASCII art of stryker. It is very cool, but I think it should only be shown once. Perhaps only for the init
command or when installing Stryker or when installing stryker-cli.
Repro steps:
npm init
and skip through itstryker init
and choose to install strykerExpected behavior:
Stryker is installed locally and the init
command is passed to it, starting the initializer
Current behavior:
Stryker is installed locally and you are suggested to run stryker --help
:
Stryker installation done.
Get started by using `stryker --help`.
Fix:
Call run()
after stryker has been installed. Merge #18 first.
We should investigate if it is possible to remove the Stryker-cli in favor of npx. That way of working is probably much easier to maintain. See how create-react-app does it:
https://github.com/facebook/create-react-app#quick-overview
@stryker-mutator/contributors What do you think about this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.