I'm writing a Node.js project using TypeScript. The compilation is done using tsc
, I am not using any task runner like Gulp or Grunt. I'll try to be as concise as possible, however if any further details are needed I'll gladly provide them.
I have the following class:
// Foo.ts
import { EventEmitter } from 'events';
export class Foo extends EventEmitter {
//...
}
When I try to test it using Jasmine with Karma and PhantomJS, I get the following error: Error: Could not find module 'events' from '(...)/foo.js'
. For me it seems that PhantomJS doesn't know where to take events
module from.
My karma.conf.js
looks as follows:
var createCoverageReport = false;
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
frameworks: ['jasmine', 'karma-typescript', 'es6-shim'],
files: [
'src/**/*.ts'
],
exclude: [
],
preprocessors: {
'src/**/*.ts': ['karma-typescript']
},
reporters: ['spec'].concat(createCoverageReport ? ['karma-typescript'] : []),
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false,
concurrency: Infinity
})
}
How can I let PhantomJS know, that the events
module comes from Node.js inner modules?