在运行我的测试时,我似乎无法修复这个错误。
09 04 2017 22:08:20.577:INFO [karma]: Karma v1.6.0 server started at http://0.0.0.0:9876/
09 04 2017 22:08:20.580:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
09 04 2017 22:08:20.602:INFO [launcher]: Starting browser PhantomJS
09 04 2017 22:08:23.661:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket SPM1D8Mj1w6ABbGuAAAA with id 7910462
PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR
SyntaxError: Use of reserved word 'let' in strict mode
at test/browser/index.js:886
我相信这在某些软件包更新期间开始发生。
我的 Karma 配置如下所示:
require('babel-register');
const webpack = require('../webpack.config.babel.js');
module.exports = function(config) {
config.set({
basePath: '../',
frameworks: ['mocha', 'chai-sinon'],
browsers: ['PhantomJS'],
files: ['test/browser/**/*.js'],
preprocessors: {
'test/**/*.js': ['webpack'],
'src/**/*.js': ['webpack']
},
webpack,
webpackMiddleware: { noInfo: true }
});
};
测试非常简单
import { h, render, rerender } from 'preact';
import { route } from 'preact-router';
import App from '../../src/components/app';
/*global sinon,expect*/
describe('App', () => {
var scratch;
before(() => {
scratch = document.createElement('div');
(document.body || document.documentElement).appendChild(scratch);
});
beforeEach(() => {
scratch.innerHTML = '';
});
after(() => {
scratch.parentNode.removeChild(scratch);
});
describe('routing', () => {
it('should render the homepage', () => {
render(<App />, scratch);
expect(scratch.innerHTML).not.contain('Home');
});
it('should render the header', () => {
render(<App />, scratch);
expect(scratch.innerHTML).to.contain('header');
});
it('should render the footer', () => {
render(<App />, scratch);
expect(scratch.innerHTML).to.contain('footer');
});
it('should render the social media links', () => {
render(<App />, scratch);
expect(scratch.innerHTML).to.contain('a');
});
});
});
知道我什至可以找出它在说哪个“让”吗?
我在 Node v7.8.0 上运行它