RSNara / node-playground

Just a test suite running mocha with chai.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Learn JavaScript using (B|T)DD!

This is a simple mocha environment that runs all specs in the /specs folder. Each file is transpiled from ES2015 + some ES2016 to ES5 using babel. An ES2015 polyfill is also provided using babel-polyfill.

Running tests

The specs:watch task below re-triggers the test run only when an existing spec file is modified.

> npm run specs
> npm run specs:watch

Test environment

The test environment tries to mimic the browser using jsdom. This means that you can even run your react component specs here! Just remember to install the react babel preset.

Expectation setup

All the expectations are handled by chai. chai.expect is available as global.expect in all specs. Object.prototype.should is also set up in the spec configuration via chai.should(). Lastly, chai is also configured to use the popular chai-as-promised library. sinon is simply installed as a convenience.

ES-Linting

Just for convenience, a sample .eslintrc file is provided. eslint is installed and uses babel-eslint as its parser. Now your spec files can look beautiful! To run the linter:

> npm run lint

About

Just a test suite running mocha with chai.js


Languages

Language:JavaScript 100.0%