Set up project:
mkdir project
cd project
yarn init -yInstall dev dependencies:
yarn add -D babel-cli babel-preset-env nodemonConfigure Babel by adding the lines below to package.json:
"babel": {
"presets": [
"env"
]
},Add some convenience scripts to package.json:
"scripts": {
"babel-node": "babel-node --presets=env",
"start": "nodemon --exec npm run babel-node -- src/",
"build": "babel src -d dist"
},To start the Node.js REPL:
yarn babel-nodeTo start the app in development mode (letting Babel interpret ES6 code):
yarn startTo build the ES5 code in the build directory from the ES6 code in the src directory:
yarn buildyarn add -D mocha chaiAdd this line to the scripts section in package.json:
"scripts": {
...
"mocha": "mocha --compilers js:babel-register",
"test": "mocha --compilers js:babel-register --recursive ./test/"
}Create a new directory called test:
mkdir testMinimal test (to save e.g. as test/test.js):
import { expect } from 'chai'
describe('test', () => {
it('should pass', () => {
expect('string').to.be.a('string')
})
})