Wallaby.js与angular 2 webpack应用程序

时间:2016-04-26 14:01:04

标签: angular webpack wallaby.js

我尝试使用Webpack为Angular 2应用程序设置Wallaby.js。我快到了,但不幸的是,我明白了。我想它必须是wallaby无法解决的import语句。

reflect-metadata shim is required when using class decorators
at undefined:
reflect-metadata shim is required when using class decorators

我的wallaby.js配置是:

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

}; }

我的测试文件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');
}));

});

我应该添加更多内容吗?我看了网,发现有一些解决方法,如require" reflect-metadata"但它不起作用。

0 个答案:

没有答案