2017-04-09 12 views
2

このエラーが発生し始めましたテストを実行するときに修正できないようです。テストを実行するときに予約語「let」を使用

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 

私はこれが特定のパッケージのアップデート中に起きたと思います。

私のカルマの設定は次のようになります。

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

私もそれが話している「せ」ているかを見つけることができるすべてのアイデアはかなり簡単ですか?

ノードv7.8.0でこれを実行しています

+1

866行目のtest/browser/index.jsファイルには何がありますか? –

+0

テストの実行中にそのファイルにどのようにアクセスできるかわかりません。 – StevieB

+0

あなたのカルマの設定に従って、そのファイルがすでにそこにあるはずです。つまり、そのディレクトリには何が入っていますか? –

答えて

-1

これは問題を解決する可能性があります。 あなたは問題がブラウザ固有である

module.exports = function(config) { 
    config.set({ 
    .... 
    files: [ 
     './node_modules/babel-polyfill/dist/polyfill.js', 
     './node_modules/phantomjs-polyfill/bind-polyfill.js', 
     'test/browser/**/*.js' 
    ], 
    .... 
    }); 
}; 
1

AS-あなたのカルマファイルにbabel-polyfillphantomjs-polyfillを追加する必要があります。したがって、ES5にソースコードをコンパイルするためにBabelを使用していない場合、テストは単にPhantomJSで実行されません。 Webpackはコンパイルをオンザフライで処理します。あなたのWebpack構成ファイルのソースを見ることができないので、問題は "webpack.config.babel.js"内のプロパティ値であると思います。

関連する問題