I try to setup Wallaby.js for the Angular 2 app with Webpack. I am almost there, but unfortunately, I get. I guess it has to be something with the import statements that wallaby is not able to resolve.
reflect-metadata shim is required when using class decorators
at undefined:
reflect-metadata shim is required when using class decorators
My wallaby.js config is:
var wallabyWebpack = require('wallaby-webpack');
var webpackPostprocessor = wallabyWebpack({
entryPatterns: [
'spec-bundle.js',
'src/**/*spec.js'
],
module: {
loaders: [
{test: /\.css$/, loader: 'raw-loader'},
{test: /\.html$/, loader: 'raw-loader'},
{
test: /\.scss$/,
exclude: /node_modules/,
loaders: ['raw-loader', 'sass-loader'] // sass-loader not scss-loader
},
]
}});
module.exports = function (w) {
return {
files: [
{pattern: 'spec-bundle.js', load: false},
{pattern: 'src/**/*.ts', load: false},
{pattern: 'src/**/*.css', load: false},
{pattern: 'src/**/*.html', load: false},
{pattern: 'src/**/*spec.ts', ignore: true}
],
tests: [
// {pattern: 'src/**/*spec.ts', load: false},
{pattern: 'src/tests/**/*spec.ts', load: false}
],
testFramework: "jasmine",
compilers: {
'**/*.ts': w.compilers.typeScript({
emitDecoratorMetadata: true,
experimentalDecorators: true
})
},
postprocessor: webpackPostprocessor,
bootstrap: function () {
window.__moduleBundler.loadTests();
}
}; }
My test file app.spec.ts:
import {
it,
inject,
injectAsync,
beforeEachProviders,
TestComponentBuilder
} from 'angular2/testing';
// Load the implementations that should be tested
import {App} from './app.component';
import {AppState} from './app.service';
describe('App', () => {
// provide our implementations or mocks to the dependency injector
beforeEachProviders(() => [
AppState,
App
]);
it('should have a url', inject([ App ], (app) => {
expect(app.url).toEqual('https://twitter.com/AngularClass');
}));
});
Should I add sth more to it? I looked the net and found that there is some workaround like require "reflect-metadata" but it does not work.