Skip to content

Commit 08f91d5

Browse files
authored
Merge pull request #355 from rackerlabs/unit-testing-coverage-report
Unit test framework for local development along with Code coverage re…
2 parents 5f76b41 + bcf6ac9 commit 08f91d5

File tree

8 files changed

+1024
-21
lines changed

8 files changed

+1024
-21
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ test/*
88

99
# files
1010
_config.*
11+
12+
# spec files
13+
src/**/*.spec.js

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ public/
1212
dist/
1313

1414
# Private credentials/config
15-
_config.private.js
15+
_config.private.js
16+
17+
# Removing Coverage Reports folder created.
18+
coverage
19+
.nyc_output

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ before_script:
2222
- yarn serve > /dev/null 2>&1 &
2323
- while ! curl --silent http://localhost:3000 > /dev/null 2>&1; do sleep 1; done
2424
script:
25+
# - yarn test:coverage
2526
- yarn lint
2627
- yarn test

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,28 @@
2222
"babel-plugin-external-helpers": "^6.22.0",
2323
"babel-preset-env": "^1.6.1",
2424
"browser-sync": "2.x",
25+
"chai": "^4.2.0",
2526
"cheerio": "^1.0.0-rc.2",
2627
"clean-css": "^4.1.9",
2728
"eslint": "4.x",
2829
"eslint-loader": "2.x",
30+
"esm": "^3.0.84",
2931
"express": "^4.16.3",
3032
"front-matter": "^2.2.0",
3133
"fs-extra": "6.x",
3234
"gh-pages": "^1.0.0",
3335
"globby": "8.x",
3436
"highlight.js": "^9.12.0",
3537
"jsdoc": "^3.5.5",
38+
"jsdom": "^12.2.0",
3639
"json5": "1.x",
3740
"less": "2.x",
3841
"less-loader": "^4.0.5",
3942
"lodash": "^4.17.4",
43+
"mocha": "^5.2.0",
4044
"moment": "^2.18.1",
4145
"nunjucks": "^3.0.1",
46+
"nyc": "^13.0.1",
4247
"raw-loader": "^0.5.1",
4348
"rollup": "0.60",
4449
"rollup-plugin-babel": "^3.0.2",
@@ -49,6 +54,8 @@
4954
"rollup-plugin-node-resolve": "^3.0.0",
5055
"rollup-plugin-uglify": "4.x",
5156
"rollup-pluginutils": "^2.0.1",
57+
"sinon": "^6.3.5",
58+
"sinon-chai": "^3.2.0",
5259
"svg-inline-loader": "^0.8.0",
5360
"tar": "^4.4.4",
5461
"uglify-es": "^3.2.2",
@@ -60,6 +67,7 @@
6067
"clean": "rm -fr node_modules",
6168
"clean:public": "bin/cleanPublic.js",
6269
"compile": "bin/compile.js",
70+
"test:coverage": "nyc --reporter=lcov mocha",
6371
"pregenerate": "yarn compile",
6472
"generate": "bin/generate.js",
6573
"preghpages": "yarn generate",
@@ -73,6 +81,7 @@
7381
"serve": "bin/serve.js",
7482
"prestart": "yarn clean:public && yarn generate",
7583
"start": "bin/start.js",
84+
"test:unit": "mocha test/run_unit.js",
7685
"test": "cd test; yarn test"
7786
},
7887
"repository": "https://github.com/rackerlabs/helix-ui.git",
@@ -81,6 +90,7 @@
8190
"Andrew Yurisich",
8291
"Cathy Siller",
8392
"Evan Nabors",
93+
"Shaleen Agarwal",
8494
"Steven Salinas",
8595
"Ty Taylor"
8696
],

src/helix-ui/utils/index.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const Utils = require('./index');
2+
3+
describe('utils', function () {
4+
it('it should have expected exports', () => {
5+
expect(Utils.KEYS).to.exist;
6+
});
7+
});

test/mocha.opts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--reporter dot

test/run_unit.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require = require('esm')(module);
2+
const jsdom = require('jsdom'); // Needed for DOM API testing
3+
const sinon = require('sinon');
4+
const chai = require('chai');
5+
const sinonChai = require('sinon-chai');
6+
const expect = chai.expect;
7+
chai.use(sinonChai);
8+
9+
global.window = new jsdom.JSDOM().window; // Needed for DOM API testing
10+
global.sinon = sinon;
11+
global.expect = expect;
12+
13+
// Add Tests Here
14+
require('../src/helix-ui/utils/index.spec');

0 commit comments

Comments
 (0)