我正在使用Node.js编写一个TypeScript项目。编译是使用tsc完成的,我没有使用像Gulp或Grunt这样的任务运行程序。我会尽量简明扼要,但是如果需要更多的细节,我很乐意提供。
我有以下课程:
// Foo.ts
import { EventEmitter } from 'events';
export class Foo extends EventEmitter {
//...
}当我尝试使用Jasmine和PhantomJS测试它时,我得到以下错误:Error: Could not find module 'events' from '(...)/foo.js'。对我来说,PhantomJS似乎不知道从哪里获取events模块。
我的karma.conf.js看起来如下:
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
})
}我如何让PhantomJS知道,events模块来自于Node.js内部模块?
https://stackoverflow.com/questions/40548113
复制相似问题