Friday, 26 May 2017

Error Cannot find module './lib-cov/express' when running karma

I am having an issue running my unit tests for my node express application. The error is occurring when I try to use "import" to pull in a class to my unit test.

This is my karma.conf.js

module.exports = function(config) {
  config.set({

    basePath: '',

    frameworks: ['browserify', 'jasmine'],

    files: [
      'node_modules/babel-polyfill/dist/polyfill.js',
      'src/**/*.js',
      'test/**/*.spec.js'
    ],

    exclude: [
    ],

    preprocessors: {
      'src/**/*.js': ['browserify'],
      'test/**/*.spec.js': ['browserify'],
    },

    browserify: {
      debug: true,
      transform: [["babelify", { "presets": ["es2015"] }]]
    },

    reporters: ['progress'],

    port: 9876,

    colors: true,

    logLevel: config.LOG_INFO,

    autoWatch: true,

    browsers: ['PhantomJS'],

    singleRun: false,

    concurrency: Infinity
  })
}

This is a picture of the error message when I run "karma start" (Covered file path so ignore that please):

Karma start error

This is my single unit test .spec.js I have:

import { Command } from '../src/command/command';

    describe('Dummy Test', () => {
      it('Lets get this test working.', () => {
        expect(true).toBe(true);
      })
    });

The src folder just contains a server.js that kicks off the Express server and some es6 classes (such as the Command class being pulled into the unit test file)



via Shawn

No comments:

Post a Comment