0
私は反応コンポーネントをテストするためにtest_helperを書きましたが、私がnpm start
を打つたびにエラーが出てきます。test_helperからのコンパイルに失敗しました
> [email protected] test /Users/WOOJUNG/Desktop/jsonplaceholder-client
> mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test
/Users/WOOJUNG/Desktop/jsonplaceholder-client/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:573
throw err;
^
SyntaxError: /Users/WOOJUNG/Desktop/jsonplaceholder-client/test/test_helper.js: Unexpected token (21:4)
19 | function renderComponent(ComponentClass, props = {}, state = {}) {
20 | const componentInstance = TestUtils.renderIntoDocument(
> 21 | <Provider store={createStore(reducers, state)}>
| ^
22 | <ComponentClass {...props} />
23 | </Provider>
24 | );
コンパイルエラーのためにエラーが発生したようです。私は確信していませんが、私が知っているようにjs:babel-core/register
はes6をコンパイルできますが失敗します。 test_helper
をコンパイルする別のオプションを教えてください。しかし、私は分かりません。 T_ T
、のように見えるあなたは '.babelrc'ファイルを含めることはできますか? –
@MichaelParkerありがとう私は '.babelrc'ファイルを忘れてしまった – gnujoow