It looks like there's something wrong with the way the webpack-transpiler loads my project.
Stryker raises a file not found error for an existing webpack configuration file.
[32m[2018-04-14 09:17:54.937] [INFO] ConfigReader - [39mUsing stryker.conf.js in the current working directory.
[32m[2018-04-14 09:17:55.493] [INFO] TypescriptConfigEditor - [39mLoading tsconfig file C:\projects\agnt\editor\frontend\tsconfig.json
[32m[2018-04-14 09:17:55.517] [INFO] ReporterOrchestrator - [39mDetected that current console does not support the "progress" reporter, downgrading to "progress-append-only" reporter
[32m[2018-04-14 09:17:55.577] [INFO] InputFileResolver - [39mFound 48 of 132 file(s) to be mutated.
[32m[2018-04-14 09:17:55.581] [INFO] InitialTestExecutor - [39mStarting initial test run. This may take a while.
[31m[2018-04-14 09:17:56.226] [ERROR] StrykerCli - [39man error occurred Error: An error occurred in transpiler "webpack". Inner error: Error: Could not load webpack config at "C:\projects\agnt\editor\frontend\config\webpack.config.dev.js", file not found.
Error: Could not load webpack config at "C:\projects\agnt\editor\frontend\config\webpack.config.dev.js", file not found.
at ConfigLoader.loaderWebpackConfigFromProjectRoot (C:\projects\agnt\editor\frontend\node_modules\stryker-webpack-transpiler\src\compiler\ConfigLoader.js:30:19)
at ConfigLoader.load (C:\projects\agnt\editor\frontend\node_modules\stryker-webpack-transpiler\src\compiler\ConfigLoader.js:14:34)
at WebpackTranspiler.<anonymous> (C:\projects\agnt\editor\frontend\node_modules\stryker-webpack-transpiler\src\WebpackTranspiler.js:20:99)
at Generator.next (<anonymous>)
at C:\projects\agnt\editor\frontend\node_modules\tslib\tslib.js:107:75
at new Promise (<anonymous>)
at Object.__awaiter (C:\projects\agnt\editor\frontend\node_modules\tslib\tslib.js:103:16)
at WebpackTranspiler.transpile (C:\projects\agnt\editor\frontend\node_modules\stryker-webpack-transpiler\src\WebpackTranspiler.js:17:24)
at TranspilerFacade.<anonymous> (C:\projects\agnt\editor\frontend\node_modules\stryker\src\transpiler\TranspilerFacade.js:30:65)
at step (C:\projects\agnt\editor\frontend\node_modules\tslib\tslib.js:133:27)
at Object.next (C:\projects\agnt\editor\frontend\node_modules\tslib\tslib.js:114:57)
at C:\projects\agnt\editor\frontend\node_modules\tslib\tslib.js:107:75
at new Promise (<anonymous>)
at Object.__awaiter (C:\projects\agnt\editor\frontend\node_modules\tslib\tslib.js:103:16)
at TranspilerFacade.performTranspileChain (C:\projects\agnt\editor\frontend\node_modules\stryker\src\transpiler\TranspilerFacade.js:23:24)
at TranspilerFacade.transpile (C:\projects\agnt\editor\frontend\node_modules\stryker\src\transpiler\TranspilerFacade.js:19:21)
at C:\projects\agnt\editor\frontend\node_modules\stryker\src\transpiler\TranspilerFacade.js:32:39
at <anonymous>
var path = require('path');
module.exports = function (config) {
config.set({
testRunner: "jest",
mutator: "typescript",
transpilers: ["webpack"],
reporter: ["clear-text", "progress", "dashboard"],
coverageAnalysis: "off",
tsconfigFile: "tsconfig.json",
mutate: ["src/**/*.ts"],
webpack: {
configFile: path.join(__dirname, "config/webpack.config.dev.js")
}
});
};
Project layout:
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
| software | version(s)
| ---------------- | -------
| node | 8.9.4 |
| npm | 5.8.0 |
| Operating System | Windows 10 x64 |
I've seen this once before. The problem is not that the file does not exist, but there is a problem consuming the file. Unfortunately the original exception is swallowed: https://github.com/stryker-mutator/stryker/blob/master/packages/stryker-webpack-transpiler/src/compiler/ConfigLoader.ts.
@Archcry can you take a look at this?
Yeah, I saw that in the code. I'm currently running a development setup to figure what is causing the real problem. Hopefully I know more soon.
Found the original problem. My webpack configuration file uses NODE_ENV as a means to inject variables into my configuration. Apparantly, the transpiler doesn't like that.
It is however hidden, because the original error is swallowed by the exception handler in https://github.com/stryker-mutator/stryker/blob/2c88af4838abd92cac870e35c763e82e445ea9f4/packages/stryker-webpack-transpiler/src/compiler/ConfigLoader.ts#L33-L39
Looking closely at the errors that got raised while loading my webpack config, it would be best if we change the loader method to look like this:
private loaderWebpackConfigFromProjectRoot(configFileLocation: string) {
if (!fs.existsSync(path.resolve(configFileLocation))) {
throw new Error(`Could not load webpack config at "${configFileLocation}", file not found.`);
}
return this.loader(path.resolve(configFileLocation));
}
I think that when the file doesn't exist, we should tell the user explicitly. The rest of the errors depends fully on what stuff you have in your configuration file. We can't anticipate that. So I would like to pass those through.
The output you get from webpack errors is clear enough for people to understand, so there's no need
for stryker to fiddle with that.
Sounds great. Do you want to prepare the PR? Did you solve your original problem?
I managed to fix my original problem. Turns out that there was a small problem in my webpack configuration that didn't pop up until I used it in combination with stryker.
Once I had that fixed I could run my tests with success. It is slow with webpack, but that's fine.
I will prepare a PR for this fix.