diff --git a/.eslintrc b/.eslintrc index 6d7de36..ede4d9d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,11 @@ { "extends": "./node_modules/eslint-config/.eslintrc", "parser": "babel-eslint", - "globals": { } + "globals": { + "before": true, + "beforeEach": true, + "describe": true, + "it": true, + "expect": true + } } diff --git a/.istanbul.yml b/.istanbul.yml new file mode 100644 index 0000000..e0c5a0b --- /dev/null +++ b/.istanbul.yml @@ -0,0 +1,9 @@ +instrumentation: + root: . + extensions: + - .js + default-excludes: true + include-all-sources: true + excludes: ['tests/**'] +reporting: + print: both diff --git a/package.json b/package.json index f80a591..12137c5 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,11 @@ "description": "", "main": "lib/index.js", "scripts": { - "build": "browserify ./lib/cli.js -o ./test/out.js", - "test": "browserify ./test/test.js -t ./lib/index.js -o ./test/out.js", - "lint": "eslint 'lib/'" + "build-cli": "browserify ./lib/cli.js -o ./bin/cli.js", + "test": "./scripts/runtests", + "lint": "eslint 'lib/'", + "coverage": "istanbul cover node_modules/.bin/_mocha -- --require scripts/test-helper.js --bail --recursive 'tests/**/*.js'", + "mocha": "mocha --require scripts/test-helper.js --bail 'tests/**/*.js'" }, "bin": "./bin/cli.js", "author": "TheOrangeOne ", diff --git a/scripts/runtests b/scripts/runtests new file mode 100755 index 0000000..187df12 --- /dev/null +++ b/scripts/runtests @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e + +echo ">> Linting..." +eslint 'lib/' + + +echo ">> Testing Build..." +browserify ./test/test.js -t ./lib/index.js -o ./test/out.js + +echo ">> Testing Project..." +npm run coverage diff --git a/scripts/test-helper.js b/scripts/test-helper.js new file mode 100644 index 0000000..995e7cc --- /dev/null +++ b/scripts/test-helper.js @@ -0,0 +1,5 @@ +const chai = require('chai'); +const sinonChai = require('sinon-chai'); + +chai.expect(); +chai.use(sinonChai); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2124b39..0000000 --- a/test/test.js +++ /dev/null @@ -1 +0,0 @@ -console.log('foobar'); diff --git a/tests/basic.test.js b/tests/basic.test.js new file mode 100644 index 0000000..88140e8 --- /dev/null +++ b/tests/basic.test.js @@ -0,0 +1,7 @@ +const expect = require('chai').expect; + +describe('Basic Mocha Setup', function () { + it('adds two and two and gets four', function () { + expect(2 + 2).to.equal(4); + }); +});