1

I am trying to get started with testing in my project. I saw many posts that said I needed to update my karma.conf.js file from angular-cli/plugins/karma to @angular-cli/plugins/karma. Anywhere where I am referencing angular-cli I put the @ symbol in front of it. This has not fixed my error.

What am I missing?

Here is the error:

06 06 2017 11:04:09.268:ERROR [config]: Error in config file!
 { Error: Cannot find module '@angular-cli/plugins/karma'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at module.exports (/.../karma.conf.js:12:7)
    at Object.parseConfig (.../node_modules/karma/lib/config.js:410:5)
    at new Server (.../node_modules/karma/lib/server.js:56:20)
    at Promise (.../node_modules/@angular/cli/tasks/test.js:34:33)
    at Class.run (.../node_modules/@angular/cli/tasks/test.js:15:16)
    at Class.run (.../node_modules/@angular/cli/commands/test.js:101:25)
    at Class.Command.validateAndRun (.../node_modules/@angular/cli/ember-cli/lib/models/command.js:128:15)
    at .../node_modules/@angular/cli/ember-cli/lib/cli/cli.js:92:22
    at tryCatch (.../node_modules/rsvp/dist/lib/rsvp/-internal.js:216:12)
    at invokeCallback (.../node_modules/rsvp/dist/lib/rsvp/-internal.js:231:13)
    at .../node_modules/rsvp/dist/lib/rsvp/then.js:29:16
    at flush (.../node_modules/rsvp/dist/lib/rsvp/asap.js:85:5) code: 'MODULE_NOT_FOUND' }

Here is my config file

// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-remap-istanbul'),
      require('@angular-cli/plugins/karma'),
      require('karma-htmlfile-reporter')
    ],
    files: [
      { pattern: './src/test.ts', watched: false }
    ],
    preprocessors: {
      './src/test.ts': ['@angular-cli']
    },
    remapIstanbulReporter: {
      reports: {
        html: 'coverage',
        lcovonly: './coverage/coverage.lcov'
      }
    },
    angularCli: {
      config: './angular-cli.json',
      environment: 'dev'
    },
    mime: {
      'text/x-typescript': ['ts','tsx']
    },
    reporters: ['progress', 'karma-remap-istanbul', 'html'],
    htmlReporter: {
      outputFile: 'tests/units.html',

      // Optional
      pageTitle: 'Unit Tests for Frontend',
      subPageTitle: 'Should always be passing.',
      groupSuites: true,
      useCompactStyle: true,
      useLegacyStyle: true
    },
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

1 Answer 1

2

remove config entry

angularCli: {
  environment: 'dev'
},

more info https://github.com/angular/angular-cli/wiki/stories-rc.0-update

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.