我正在使用Uncaught ReferenceError: require is not defined
获得jasmine
单元测试中的karma
。
这是我的karma.conf.js
文件。
tsconfig.json
- 目标"target": "es6"
module.exports = function (config) {
config.set({
basePath: './',
frameworks: ['jasmine'],
files: [
'node_modules/reflect-metadata/Reflect.js',
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/systemjs/dist/system.src.js',
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
{ pattern: 'dist/dev/**/*.js', included: false, watched: true },
{ pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false }, // PhantomJS2 (and possibly others) might require it
'dist/**/*.spec.js',
],
proxies: { },
exclude: [ ],
preprocessors: {
'dist/**/!(*spec).js': ['coverage']
},
reporters: ['mocha', 'coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: [
'PhantomJS',
'Chrome'
],
singleRun: false,
client: { }
});
};
答案 0 :(得分:0)
建议使用额外--module commonjs
编译代码并使用了解commonjs的karma插件,即https://github.com/karma-runner/karma-commonjs