Skip to content

Instantly share code, notes, and snippets.

@KyFaSt
Last active December 3, 2015 20:25
Show Gist options
  • Save KyFaSt/d41ce06acf756c54ea01 to your computer and use it in GitHub Desktop.
Save KyFaSt/d41ce06acf756c54ea01 to your computer and use it in GitHub Desktop.
ES6 Mocha Testing
language: node_js
node_js:
- "4.1"

Setup for ES6 unit testing

NPM packages:

Directory structure

├── package.json
├── dist
│   ├── script.js
├── test
│   ├── mocha
│   │   └── parser_test.js
│   └── test_runner.js
├── src
│   ├── Main.js
│   └── Parser.js

--ui tdd
--recursive
{
"name": "playground",
"version": "0.0.1",
"description": "A playground to make real web requests to an API",
"devDependencies": {
"babel": "6.0.0",
"babel-core": "^6.2.1",
"babel-preset-es2015": "^6.1.2",
"babelify": "^7.2.0",
"browserify": "^12.0.1",
"chai": "^3.4.1",
"mocha": "^2.3.4",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0",
"watchify": "^3.6.1"
},
"scripts": {
"prebuild": "rm -rf dist && mkdir dist",
"build": "./node_modules/.bin/watchify src/Main.js -o dist/script.js -t [ babelify ]",
"test": "mocha --compilers js:babel-core/register"
},
"babel": {
"presets": ["es2015"]
}
}
import Parser from "../../src/Parser"
import * as test from "../test_runner.js"
describe("Parser", function(){
})
import sinon from "sinon"
import sinonChai from "sinon-chai"
import chai from "chai"
chai.use(sinonChai)
export var expect = chai.expect
suite('Array', function() {
beforeEach(function(){
this.sandbox = sinon.sandbox.create()
});
afterEach(function(){
this.sandbox.restore()
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment