How to transfer ES6 imports to Chai?

I use the minimum minimum setting for a responsive application:

  • Webpack
  • Babel
  • React + Flux
  • Mocha and Tea for testing

I want to test my application now.

I have a .babelrc with the following contents:

{
  "presets": ["es2015"],
  "ignore": false
}

And my test is as follows:

import { expect, assert } from 'chai';
import AppStore from '../src/js/stores/app-store';

describe('app store', () => {
  assert.equal(3,3);
});

When I comment on the second import, it works.

When I import my AppStore, I get this error message:

(function (exports, require, module, __filename, __dirname) { import { dispatch, register } from '../dispatchers/app-dispatcher';
                                                              ^^^^^^

SyntaxError: Unexpected token import

So, I apparently rewrite the test.js file , but the import will not move to ES5.

What should I do, what does the minimal setup look like (without using Grunt or anything else).

EDIT: My node scripts inside package.json look like this:

  "scripts": {
    "dev": "webpack && webpack-dev-server",
    "test": "mocha --compilers js:babel-core/register --recursive"
  },
+4
source share
1

. stackoverflow , package.json :

  "babel": {
    "presets": [
      "es2015"
    ]
  }

ES6 . , webpack.config.js, , , -.

0

Source: https://habr.com/ru/post/1624769/


All Articles