2017-04-09 6 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

문제 된 직후 당신의 카르마 파일을 babel-polyfillphantomjs-polyfill를 추가해야하는 브라우저 별이다. 따라서 Babel을 사용하여 소스 코드를 ES5로 컴파일하지 않으면 테스트는 PhantomJS에서 실행되지 않습니다. Webpack은 컴파일을 즉석에서 처리합니다. Webpack 구성 파일의 원본을 볼 수 없기 때문에 문제는 "webpack.config.babel.js"내의 속성 값입니다.