wmakeev
7/26/2015 - 8:11 AM

ES6 Testing With Mocha and BabelJS

ES6 Testing With Mocha and BabelJS

if (!process.env.NODE_ENV || process.env.NODE_ENV.toLowerCase().trim().substr(0,3) === 'dev') {
  console.log('opening coverage report coverage/lcov-report/index.html');
  require('open')(__dirname + '/../coverage/lcov-report/index.html');
}
{
  "config": {
    "MOCHA_OPTS": "--recursive test/unit/",
    "ISPARTA_OPTS": "--report html",
    "COVERAGE_OPTS": "--statements 100 --functions 100 --branches 100 --lines 100"
  },
  "scripts": {
    "clean": "rimraf ./dist",
    "build": "babel ./src --experimental --source-maps-inline -d ./dist",
    "lint": "npm run lint-src && npm run lint-test",
    "lint-src": "eslint src",
    "lint-test": "eslint test --global describe,it,beforeEach,afterEach --rule no-unused-expressions:false ",
    "unit": "babel-node -r node_modules/.bin/_mocha $npm_package_config_MOCHA_OPTS",
    "coverage": "babel-node -r node_modules/.bin/isparta cover $npm_package_config_ISPARTA_OPTS node_modules/.bin/_mocha -- $npm_package_config_MOCHA_OPTS",
    "coverage-check": "node node_modules/isparta/node_modules/istanbul/lib/cli check-coverage $npm_package_config_COVERAGE_OPTS",
    "show-report": "node test/open-coverage-report",
    "test": "npm run lint && npm run coverage && (npm run coverage-check || node scripts/open-coverage-report)"
  },
  "devDependencies": {
    "eslint": "^0.17.0",
    "babel": "^4.7.12",
    "chai": "^2.1.1",
    "isparta": "^2.2.0",
    "mocha": "^2.2.1",
    "open": "0.0.5",
    "proxyquire": "^1.4.0",
    "sinon": "^1.13.0",
    "sinon-chai": "^2.7.0"
  }
}
{
  "ecmaFeatures": {
    "arrowFunctions": true,
    "binaryLiterals": false,
    "blockBindings": true,
    "classes": true,
    "defaultParams": true,
    "destructuring": true,
    "forOf": true,
    "generators": true,
    "modules": false,
    "objectLiteralComputedProperties": true,
    "objectLiteralDuplicateProperties": false,
    "objectLiteralShorthandMethods": true,
    "objectLiteralShorthandProperties": true,
    "octalLiterals": false,
    "regexUFlag": false,
    "regexYFlag": false,
    "superInFunctions": false,
    "templateStrings": true,
    "unicodeCodePointEscapes": false,
    "globalReturn": false,
    "jsx": false
  },
  "rules": {
    "strict": "never",
    "quotes": "single",
    "curly": "multi-line",
    "comma-style": "first",
    "comma-spacing": "off",
    "no-use-before-define": "nofunc",
    "no-trailing-spaces": false,
    "no-underscore-dangle": false
  },
  "globals": {
    //from node
    "require": false,
    "module": false,
    "exports": false,
    "process": false,
  }
}