stryker-mutator / stryker-cli

The command-line interface for Stryker, the JavaScript mutation testing framework
http://stryker-mutator.github.io
Apache License 2.0
10 stars 1 forks source link

'Stryker run' fails with html reporter enabled when Stryker is installed with 'stryker init' on a new Angular project #35

Closed maxhov closed 5 years ago

maxhov commented 5 years ago

When initializing Stryker with stryker init on a new Angular project, the Stryker CLI installs the dev package 'stryker-html-reporter' instead of the dev package '@stryker-mutator/html-reporter' (as indicated by in the Angular handbook). This causes stryker run to fail when run directly after stryker init with the following error message:

12:22:54 (13034) INFO ConfigReader Using stryker.conf.js in the current working directory.
12:22:54 (13034) WARN PluginLoader Error during loading "~/project/node_modules/@stryker-mutator/karma-runner" plugin:
  Cannot find module 'karma'
12:22:54 (13034) WARN PluginLoader Error during loading "~/project/node_modules/@stryker-mutator/typescript" plugin:
  Cannot find module 'typescript'
12:22:54 (13034) ERROR StrykerCli an error occurred { Error: Could not inject "InputFileResolver". Inner error: Could not inject "BroadcastReporter". Inner error: Cannot load Reporter plugin "html". Did you forget to install it? Loaded Reporter plugins were: clear-text, progress, progress-append-only, dots, event-recorder, dashboard
    at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:35:19)
    at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:95:22)
    at Stryker.<anonymous> (~/project/node_modules/@stryker-mutator/core/src/Stryker.js:62:60)
    at step (~/project/node_modules/tslib/tslib.js:133:27)
    at Object.next (~/project/node_modules/tslib/tslib.js:114:57)
    at fulfilled (~/project/node_modules/tslib/tslib.js:104:62)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
  innerError:
   { Error: Could not inject "BroadcastReporter". Inner error: Cannot load Reporter plugin "html". Did you forget to install it? Loaded Reporter plugins were: clear-text, progress, progress-append-only, dots, event-recorder, dashboard
       at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:35:19)
       at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:95:22)
       at ClassProvider.result (~/project/node_modules/typed-inject/src/InjectorImpl.js:173:21)
       at ClassProvider.resolveInternal (~/project/node_modules/typed-inject/src/InjectorImpl.js:131:36)
       at ClassProvider.resolve (~/project/node_modules/typed-inject/src/InjectorImpl.js:70:21)
       at ClassProvider.resolve (~/project/node_modules/typed-inject/src/InjectorImpl.js:103:22)
       at FactoryProvider.resolveInternal (~/project/node_modules/typed-inject/src/InjectorImpl.js:142:32)
       at FactoryProvider.resolve (~/project/node_modules/typed-inject/src/InjectorImpl.js:70:21)
       at FactoryProvider.resolve (~/project/node_modules/typed-inject/src/InjectorImpl.js:103:22)
       at ClassProvider.resolveInternal (~/project/node_modules/typed-inject/src/InjectorImpl.js:142:32)
     innerError:
      Error: Cannot load Reporter plugin "html". Did you forget to install it? Loaded Reporter plugins were: clear-text, progress, progress-append-only, dots, event-recorder, dashboard
          at PluginLoader.resolve (~/project/node_modules/@stryker-mutator/core/src/di/PluginLoader.js:31:23)
          at PluginCreator.create (~/project/node_modules/@stryker-mutator/core/src/di/PluginCreator.js:11:42)
          at BroadcastReporter.createReporter (~/project/node_modules/@stryker-mutator/core/src/reporters/BroadcastReporter.js:23:59)
          at ~/project/node_modules/@stryker-mutator/core/src/reporters/BroadcastReporter.js:15:79
          at Array.forEach (<anonymous>)
          at new BroadcastReporter (~/project/node_modules/@stryker-mutator/core/src/reporters/BroadcastReporter.js:15:32)
          at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:32:20)
          at ClassProvider.injectClass (~/project/node_modules/typed-inject/src/InjectorImpl.js:95:22)
          at ClassProvider.result (~/project/node_modules/typed-inject/src/InjectorImpl.js:173:21)
          at ClassProvider.resolveInternal (~/project/node_modules/typed-inject/src/InjectorImpl.js:131:36) } }
12:22:54 (13034) INFO StrykerCli Trouble figuring out what went wrong? Try `npx stryker run --fileLogLevel trace --logLevel debug` to get some more info.

Repro steps

  1. Initialize new Angular project with ng new <project name>
  2. Initialize Stryker by running stryker init
  3. Run Stryker with stryker run

Versions

Angular-cli: 7.3.4 Stryker-cli: 1.0.3

stryker.conf.js

// This config was generated using a preset.
// Please see the handbook for more information: https://github.com/stryker-mutator/stryker-handbook/blob/master/stryker/guides/angular.md#angular
module.exports = function(config) {
  config.set({
    mutate: [
      "src/**/*.ts",
      "!src/**/*.spec.ts",
      "!src/test.ts",
      "!src/environments/*.ts"
    ],
    mutator: "typescript",
    testRunner: "karma",
    karma: {
      configFile: "src/karma.conf.js",
      projectType: "angular-cli",
      config: {
        browsers: ["ChromeHeadless"]
      }
    },
    reporters: ["progress", "clear-text", "html"],
    maxConcurrentTestRunners: 2, // Recommended to use about half of your available cores when running stryker with angular.
    coverageAnalysis: "off"
  });
};

Expected behaviour

@stryker-mutator/html-reporter' html reporter is installed by Stryker-cli as per Angular handbook

Actual behaviour

stryker-html-reporter dev package is installed.

nicojs commented 5 years ago

Thanks for reporting this issue. We've fixed it in https://github.com/stryker-mutator/stryker/pull/1434 and a new release is launching as we speak 🚀

nicojs commented 5 years ago

It should be solved now, as of @stryker-mutator/core@1.1.x

+ @stryker-mutator/core@1.1.0
+ @stryker-mutator/typescript@1.1.0
+ @stryker-mutator/html-reporter@1.1.0
+ @stryker-mutator/karma-runner@1.1.0