Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage analysis isn't working correctly when different versions of stryker-api are mixed-and-matched #2025

Closed
nicojs opened this issue Feb 12, 2020 · 1 comment · Fixed by #2042 or #2124
Assignees
Labels
🐛 Bug Something isn't working
Milestone

Comments

@nicojs
Copy link
Member

nicojs commented Feb 12, 2020

Summary

Given the following directory structure:

node_modules/
└── @stryker-mutator/
    ├── core
    │     └── node_modules/@stryker-mutator/api
    └── typescript
          └── node_modules/@stryker-mutator/api

When running stryker run here, the coverage analysis perTest is broken.

Stryker config

module.exports = function(config){
  config.set({
    coverageAnalysis: 'perTest'
  });
}

Details

For some time now, @stryker-mutator/api is a direct dependency for core as well es all other plugins. The idea is that, since the api doesn't have direct side effects, it is OK to depend on it and it would be OK if the version used by a plugin is different from the core.

The api does have some class implementations, in particular File.ts. Instances of this class are serialized and deserialized using surrial.

However, this can break serialization/deserialization. The transpiler new's it's own File instances (for example, here). The File constructor class used by the plugin is unrelated to the one used in core. This makes it so it is NOT serialized as an instance of File by surrial. Later, when stryker tries to compare file content using the textContent property it never notices the changes, since it will be comparing undefined === undefined.

Workaround

The (only) workaround is to make sure that @stryker-mutator/api is hoisted to the top level of your node_modules. This should be the case when your stryker version is in sync.

node_modules/
└── @stryker-mutator/
    ├── core
    ├── typescript
    └── api
@nicojs nicojs added the 🐛 Bug Something isn't working label Feb 12, 2020
@nicojs nicojs added this to the 3.0 milestone Feb 12, 2020
nicojs added a commit to stryker-mutator/mutation-testing-elements that referenced this issue Feb 12, 2020
Make sure the @stryker-mutator/api package is hoisted to toplevel.

Workaround for: stryker-mutator/stryker-js#2025
nicojs added a commit to stryker-mutator/mutation-testing-elements that referenced this issue Feb 12, 2020
Make sure the @stryker-mutator/api package is hoisted to toplevel.

Workaround for: stryker-mutator/stryker-js#2025
@nicojs nicojs self-assigned this Feb 12, 2020
nicojs added a commit that referenced this issue Feb 14, 2020
Customize the way we serialize files to make sure different versions of stryker-api can be mixed and matched (although not recommended).

Fixes #2025
nicojs added a commit that referenced this issue Feb 16, 2020
Customize the way we serialize files to make sure different versions of `stryker-api` can be mixed and matched (although not recommended).

Fixes #2025

Co-authored-by: Simon de Lang <simondelang@gmail.com>
@nicojs
Copy link
Member Author

nicojs commented Mar 28, 2020

This wasn't fixed after all, because of nicojs/node-surrial#9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
1 participant