我正在使用TypeScript編寫Node.js項目。編譯完成使用tsc
,我沒有使用任何像Gulp或Grunt任務運行。我會盡量簡潔,但如果需要更多細節,我會很樂意提供。Karma測試,PhantomJS錯誤:無法找到模塊'事件'
我有下面的類:
// Foo.ts
import { EventEmitter } from 'events';
export class Foo extends EventEmitter {
//...
}
當我嘗試使用茉莉花與噶和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的內部模塊?
有關於此的任何更新?這裏同樣的問題 – CTodea