Hello,
I have an angular project, but I don't use karma, I use @angular-builders/jest.
Is there anyway I can start the tests with the angular starter (ng test) without the karma test runner?
Thanks in advance
Hi @miguel-leon 馃憢 Thanks for your interest.
We actually didn't have time yet to implement this feature. Do you have any idea how @angular-builders/jest works? Is it just calling jest? Or adding some more magic. Once we know that, we should be able to support it with our jest-runner stryker-mutator plugin.
Hello @nicojs ! Thanks for your response.
I know it uses a recent angular-cli api called builders which was a replacement for ng eject. To make it work one only has to plug out the builder @angular-devkit/build-angular:karma in the angular.json and plug in @angular-builders/jest:run after installing jest and @types/jest.
It has to be ran with ng test, actually just calling jest won't work because there is no jest.config.js or further configuration.
I checked out some of the stryker's source code because I saw it can be configured to run with ng test, but it seems to be hard coded to karma, hence my question. How can the angular starter be separated from karma and run independently?
Thanks again!
Yeah, the current implementation is hardcoded to karma. We use ng test from inside a sandbox process (worker process) and hook up to it by supplying our very own karma.conf.js, which in turn loads your custom karma config. This way of working is needed to plug our own karma reporter which reports the test results back to Stryker. This is also how the webstorm karma runner plugin hooks into angular cli (https://github.com/karma-runner/karma-intellij).
We might be able to do something similar for jest with ng cli and our jest-runner stryker plugin. Do you think you would be able to implement something like this? Or investigate if this is possible?
Hi @nicojs,
I see what you mean. I think it may be possible doing something similar with jest since ng test can be used with the argument --config-path instead of using --karma-config. The argument --progress is unknown though.
The thing is I know little about how test runners and reporters work. I didn't realize you had to do that config wrapping to specify your custom reporter. I'd have to dig deeper into it.
But I didn't find such a reporter for jest or where the jest command is executed (in fact the ensamble is sorta different from karma's). Do you think that if ng test can be called with a custom jest config the rest of the jest-runner stryker plugin can be used as is?
The jest-runner plugin doesn't use a custom reporter to retrieve the test results, no. However, I do think you need it in the case of ng test, since running the ng test command only results in an "exitCode" (which is pretty much useless).
As you can see, the jest-runner relies on the RunResult which is retrieved from running jest programmatically
This might be a good time to create a separate angular-cli-runner plugin that supports both karma and jest, instead of rewriting each test runner to support different project types. More thinking is needed for this... 馃し鈥嶁檧
Hey folks,
@nicojs thanks for all your work with stryker.
I'm happy to announce that I've made a PR to support mutation testing on nrwl/nx workspaces.
The package includes the mutate builder and configuration schematics that will help scaffold stryker easily with the config file.
This works for jest and karma.
@miguel-leon
@SebasG22 I've seen the PR, but they are not going to implement it because it is out of scope of nrwl/nx. Is it possible to have a look at adding nrwl/nx to the wizard when installing stryker-mutator?
Most helpful comment
The jest-runner plugin doesn't use a custom reporter to retrieve the test results, no. However, I do think you need it in the case of
ng test, since running theng testcommand only results in an "exitCode" (which is pretty much useless).As you can see, the jest-runner relies on the
RunResultwhich is retrieved from running jest programmaticallyThis might be a good time to create a separate
angular-cli-runnerplugin that supports both karma and jest, instead of rewriting each test runner to support different project types. More thinking is needed for this... 馃し鈥嶁檧