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

442 Views Asked by At

I seem to be setting up wallable wrong.

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 set up my js file like so:

    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 just found this tool today and am very excited to get it to work. I also have my project on GitHub Git 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 my wallaby.js file to make sure it was not using the compiler since wallaby has it's own.

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

However I still get the same error.

1

There are 1 best solutions below

0
On

As @YaroslavAdmin correctly mentioned, the important bit is src/wallabyTest.ts - it's where the polyfills are loaded from. You have this file missing in your project.