我似乎设置了可错的故障。
错误:
ReferenceError: Can't find variable: Map
at src/app/home/home.component.spec.ts:4
ReferenceError: Can't find variable: Map
at http://localhost:63247/__modules/27.js?1483285680907:80
我设置了js
文件,如下所示:
var wallabyWebpack = require('wallaby-webpack');
var webpackPostprocessor = wallabyWebpack({
entryPatterns: [
'src/wallabyTest.js',
'src/**/*spec.js'
],
module: {
loaders: [
{test: /\.css$/, loader: 'raw-loader'},
{test: /\.html$/, loader: 'raw-loader'},
{test: /\.js$/, loader: 'angular2-template-loader', exclude: /node_modules/},
{test: /\.json$/, loader: 'json-loader'},
{test: /\.styl$/, loaders: ['raw-loader', 'stylus-loader']},
{test: /\.less$/, loaders: ['raw-loader', 'less-loader']},
{test: /\.scss$|\.sass$/, loaders: ['raw-loader', 'sass-loader']},
{test: /\.(jpg|png)$/, loader: 'url-loader?limit=128000'}
]
}
});
var compilerOptions = require('./src/tsconfig.json').compilerOptions;
module.exports = function (wallaby) {
return {
files: [
{pattern: 'src/**/*.ts', load: false},
{pattern: 'src/**/*.d.ts', ignore: true},
{pattern: 'src/**/*.css', load: false},
{pattern: 'src/**/*.html', load: false},
{pattern: 'src/**/*spec.ts', ignore: true},
{pattern: 'node_modules/babel-polyfill/browser.js', instrument: false}
],
tests: [
{pattern: 'src/**/*spec.ts', load: false}
],
testFramework: 'jasmine',
compilers: {
'**/*.ts': wallaby.compilers.typeScript(compilerOptions)
},
postprocessor: webpackPostprocessor,
setup: function () {
window.__moduleBundler.loadTests();
},
debug: true
};
};
项目结构:
我今天刚刚找到这个工具,我很高兴能让它发挥作用。我的项目也在 GitHub Git Hub Link
上ReferenceError: Can't find variable: Map
at src/app/home/home.component.spec.ts:4
经过一些研究后,我将以下内容添加到我的wallaby.js文件中,以确保它不使用编译器,因为小袋鼠拥有它。
{pattern: 'node_modules/babel-polyfill/browser.js', instrument: false}
但是我仍然得到同样的错误。
答案 0 :(得分:0)
正如@YaroslavAdmin正确提到的那样,重要的一点是src/wallabyTest.ts
- 它是从哪里加载polyfill的。您的项目中缺少this file。