Stryker: typescript perTest issue

Created on 22 Dec 2018  路  5Comments  路  Source: stryker-mutator/stryker

If you use config like this:

module.exports = function(config) {
  config.set({
    mutator: "typescript",
    packageManager: "npm",
    reporters: ["html", "clear-text", "progress"],
    testRunner: "mocha",
    transpilers: ["typescript"],
    testFramework: "mocha",
    coverageAnalysis: "perTest",
    tsconfigFile: "tsconfig.json",
    mutate: ["src/**/*.ts"]
  });
};

You get error:
15:13:26 (11408) ERROR StrykerCli an error occurred { Error: Source map not found for "C:\Users\19gro\Desktop\BigMath\src\bm.d.ts". Cannot analyse code coverage. Setting coverageAnalysis: "off" in your stryker.conf.js will prevent this error, but forces Stryker to run each test for each mutant.

Example in https://github.com/kmdrGroch/BigMath (just change this in the config and so you can see it)

Everything works while using coverageAnalysis: "off"

hacktoberfest 馃悰 Bug

Most helpful comment

Sorry @sprengerjo but I don't like this approach: .filter(mutateFile => !mutateFile.name.endsWith('.d.ts')). This adds specific source code knowledge to the Stryker core. Right now, it doesn't know any typescript/javascript specifics. I would like to keep it that way. This also doesn't guard agains missing .map files for other input files.

@kmdrGroch out of curiosity, why do you check-in build output files? If you don't do that, Stryker will know to note mutate *.d.ts files for free. I'm not sure if this even needs to be fixed.

I've created a PR at your side to fix the issue: https://github.com/kmdrGroch/BigMath/pull/22

All 5 comments

Interesting issue. Question: do you actually want bm.d.ts to be mutated here?

nope. Since it's only declaration file and it's created by typescript automatically. Since i do tsc -p . first and then stryker run

So the workaround is: mutate: ["src/**/*.ts", "!src/**/*.d.ts"]. Still Stryker shouldn't break, it should just run all tests if need be.

Sorry @sprengerjo but I don't like this approach: .filter(mutateFile => !mutateFile.name.endsWith('.d.ts')). This adds specific source code knowledge to the Stryker core. Right now, it doesn't know any typescript/javascript specifics. I would like to keep it that way. This also doesn't guard agains missing .map files for other input files.

@kmdrGroch out of curiosity, why do you check-in build output files? If you don't do that, Stryker will know to note mutate *.d.ts files for free. I'm not sure if this even needs to be fixed.

I've created a PR at your side to fix the issue: https://github.com/kmdrGroch/BigMath/pull/22

Thanks, @nicojs! I was probably just doing something really bad :x Closing with this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLanglet picture VincentLanglet  路  31Comments

nicojs picture nicojs  路  17Comments

simondel picture simondel  路  17Comments

anthony-telljohann picture anthony-telljohann  路  19Comments

jeznag picture jeznag  路  17Comments