stryker-mutator / stryker-handbook

A comprehensive guide to the stryker ecosystem
Apache License 2.0
71 stars 11 forks source link

Add Angular guide #2

Closed simondel closed 6 years ago

simondel commented 6 years ago

This guide is meant to help users who want to use Stryker with an Angular project.

simondel commented 6 years ago

@nicojs @Archcry @blabno feedback is very welcome!

blabno commented 6 years ago

For me the default dependencies generated by ng new were too old and stryker told me only about one of them:

 "@angular-devkit/build-angular": "~0.6.8",
 "@angular/cli": "~6.0.8",

I had to update both to:

"@angular-devkit/build-angular": "~0.7.2",
"@angular/cli": "~6.1.0",

Configuring stryker is also not intuitive. I thought that since my tests use jasmine then I should set testFramework: "jasmine", but that leads to

SyntaxError: 'import' and 'export' may appear only with 'sourceType: "module"' (1:0)

Next thing was karma.project property in stryker.conf.js. The documentation on homepage https://github.com/stryker-mutator/stryker/tree/master/packages/stryker#readme did not mention how that karma part should be configured. I know you can reach it by going to https://stryker-mutator.io/plugins.html and then to stryker-karma-runner readme on GitHub, but it's not intuitive. My intuition told me to set it to the name of my project and I didn't get a message that the value is invalid. Instead, I got a cryptic message:

Error: The '@angular-devkit/build-angular/plugins/karma' karma plugin is meant to be used from within Angular CLI and will not work correctly outside of it which was very misleading as my next attempt was trying to remove that plugin from karma.conf.js.

I finally managed to configure stryker properly thanks to sample from integration tests although running that one was hell as well.

nicojs commented 6 years ago

Great idea to document this further, but shouldn't this be placed on our wiki? See https://github.com/stryker-mutator/stryker/wiki/Configuration . This is a start for working with presets: https://github.com/stryker-mutator/stryker/issues/1049

So should be moved to the Stryker-handbook as discussed in that issue. Right @_simondel? Just want to make sure we keep things DRY, I don't want to end up with multiple places

simondel commented 6 years ago

@nicojs as we recently discussed, the wiki cannot be properly used to collaborate with others due to lacking PR support.

I'd like to see the documentation in the wiki be migrated to this repo. Then we can point to this repo from the wiki (just like TypeScript does).

nicojs commented 6 years ago

That's what I mean. Can we move this PR to the new Stryker-Handbook?

simondel commented 6 years ago

@nicojs this PR is on the new stryker-handbook repo 🙈

nicojs commented 6 years ago

Wow cool! Didn't realize. I'm on vacation and only have my phone. Proceed.

nicojs commented 6 years ago

You have to mention minimum valid version of @angular-devkit/build-angular cause ~0.6.8 was causing stryker to hang in the middle of tests.

@blabno I didn't realize that the build-angular dependency was not automatically updated with @angular/cli. Should we also add a runtime check like we have for the cli?

blabno commented 6 years ago

@nicojs when I've read info about upgrading angular cli i've just bumped the version inside package.json, so if there is another way that bumps both cli and devkit then probably it should be documented and printed with that error message.

nicojs commented 6 years ago

I'm happy, let's do this