Skip to content

Commit 0d5ccdf

Browse files
authored
Merge pull request #7 from MarcL/day6
Day 6 : Simplify and automate your tests
2 parents 50fdc9f + ef42743 commit 0d5ccdf

File tree

8 files changed

+24
-18
lines changed

8 files changed

+24
-18
lines changed

doc/notes.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242

4343
## Day 6 - Simplify & automate your tests
4444

45-
1. Put test call in package.json script
46-
2. Refactor tests using mocha.opts
47-
3. Add mocha watch command
48-
4. Skipping tests
49-
5. Isolating tests
50-
6. Increase timeouts
51-
7. Install husky
45+
1. Customising your package.json scripts
46+
2. Add mocha watch command
47+
3. Refactor tests using mocha.opts
48+
4. Recursive testing
49+
5. Skipping tests
50+
6. Isolating tests
51+
7. Install git hooks
5252
8. Run tests when commit or push
5353

5454
## Day 7 - JavaScript testing recap

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"precommit": "npm test",
8+
"prepush": "npm test",
9+
"test": "mocha",
10+
"test:watch": "mocha --watch"
811
},
912
"repository": {
1013
"type": "git",
@@ -21,6 +24,7 @@
2124
"babel-preset-env": "~1.6.0",
2225
"babel-register": "~6.24.1",
2326
"chai": "~4.1.1",
27+
"husky": "~0.14.3",
2428
"mocha": "~3.5.0",
2529
"sinon": "~3.2.1"
2630
},

test/mocha.opts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--require babel-register
2+
--recursive
3+
--require test/support

test/support.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {expect} from 'chai';
2+
import sinon from 'sinon';
3+
4+
global.expect = expect;
5+
global.sinon = sinon;

test/day2.test.js renamed to test/unit-tests/day2.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {expect} from 'chai';
2-
import day2 from '../src/day2';
1+
import day2 from '../../src/day2';
32

43
describe('day2 tests', () => {
54
describe('check data type', () => {

test/day3.test.js renamed to test/unit-tests/day3.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {expect} from 'chai';
2-
import day3 from '../src/day3';
1+
import day3 from '../../src/day3';
32

43
describe('day 3 tests', () => {
54
it('should return expected value from callback', (done) => {

test/day4.test.js renamed to test/unit-tests/day4.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import sinon from 'sinon';
2-
import {expect} from 'chai';
3-
import {timeout, dateDescriber} from '../src/day4';
1+
import {timeout, dateDescriber} from '../../src/day4';
42

53
describe('day 4 tests', () => {
64
describe('timeout tests', () => {

test/day5.test.js renamed to test/unit-tests/day5.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import {expect} from 'chai';
2-
import sinon from 'sinon';
31
import request from 'request';
4-
import day5 from '../src/day5';
2+
import day5 from '../../src/day5';
53

64
describe('day5 tests', () => {
75

0 commit comments

Comments
 (0)