6

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.

Mike3355
  • 11,305
  • 24
  • 96
  • 184
  • You didn't include polyfills. See the first link in the [section](https://wallabyjs.com/docs/integration/angular.html#angular-2) for example, how to properly configure it for Angular 2. The important bit is `src/wallabyTest.ts`. – Yaroslav Admin Dec 31 '16 at 14:11
  • @YaroslavAdmin I am trying to figure it out, thanks for the link. Do you know where I can find a working example? – Mike3355 Dec 31 '16 at 14:27
  • First link in that section claims to be working example: [Angular.js 2 angular-cli (Webpack) generated project](https://github.com/wallabyjs/ngCliWebpackSample#wallabyjs). – Yaroslav Admin Dec 31 '16 at 14:32
  • @YaroslavAdmin please see updated post – Mike3355 Jan 01 '17 at 16:16
  • @YaroslavAdmin I added a bounty and changed my post. – Mike3355 Jan 02 '17 at 14:01
  • Sorry, don't have time to debug it at the moment. Maybe will have a look on the weekend. – Yaroslav Admin Jan 02 '17 at 15:40

1 Answers1

0

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.

Artem Govorov
  • 903
  • 6
  • 10