Run the following shell commands:
npm init
npm i --save-dev mocha chai babel-register babel-preset-es2015
Open up package.json
and set your test script to the following:
mocha --watch --compilers js:babel-core/register
Create a .babelrc
file in the project directory:
{
"presets": ["es2015"]
}
// test/main.test.js
import { expect } from 'chai';
import Main from '../src/main';
describe('Main', () => {
it('should be a class', () => {
expect(new Main()).to.not.equal(undefined);
});
});
// src/main.js
export default class Main {
constructor() {
}
}
> npm run test
Main
✓ should be a class
1 passing (12ms)
Thank you this was very helpful!