ReferenceError: cannot find variable: Map in src / app / home / home.component.spec.ts: 4 Angular 2

It seems I am not adjusting the surface correctly.

Error:

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 

I installed my js file as follows:

  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 }; }; 

Project Structure:

enter image description here

enter image description here

I found this tool today and am very glad that it works. I also have my GitHub Git project. Hub link

 ReferenceError: Can't find variable: Map at src/app/home/home.component.spec.ts:4 

After some research, I added the following to the wallaby.js file to make sure that it does not use the compiler, since wallaby has it.

{pattern: 'node_modules/babel-polyfill/browser.js', instrument: false}

However, I still get the same error.

+6
source share
1 answer

As @YaroslavAdmin correctly mentioned, the important bit - src/wallabyTest.ts - is where policies are downloaded. You do not have this file in your project.

0
source

Source: https://habr.com/ru/post/1013654/


All Articles