Skip to content

Commit ef5beec

Browse files
committed
Added Testing library and travis ci
1 parent ab3c1a0 commit ef5beec

File tree

7 files changed

+37
-5
lines changed

7 files changed

+37
-5
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- "6"

build_scripts/test-config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This file isn't transpiled, so must use CommonJS and ES5
2+
3+
// Register babel to transpile before our tests run.
4+
require('babel-register');
5+
6+
// Disable webpack features that Mocha doesn't understand.
7+
require.extensions['.css'] = function () {};

index.test.js

Whitespace-only changes.

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
"license": "MIT",
99
"scripts": {
1010
"prestart": "babel-node build_scripts/development-server-start-message.js",
11-
"start": "npm-run-all --parallel security-check start:development:server",
11+
"start": "npm-run-all --parallel security-check start:development:server lint:watch test:watch",
1212
"start:development:server": "babel-node build_scripts/development-server.js",
1313
"start:production:server": "",
1414
"security-check": "nsp check",
1515
"localtunnel": "lt --port 3001",
1616
"share:development": "npm-run-all --parallel start:development:server localtunnel",
17-
"lint": "esw webpack.config.* src --color",
18-
"lint:watch": "npm run lint -- --watch"
17+
"lint": "esw webpack.config.* src --fix --color",
18+
"lint:watch": "npm run lint -- --watch",
19+
"test": "mocha --reporter progress build_scripts/test-config.js \"src/**/*.test.js\"",
20+
"test:watch": "npm run test -- --watch"
1921
},
2022
"dependencies": {
2123
"whatwg-fetch": "^2.0.3",

src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
<script src="bundle.js"></script>
77
</head>
88
<body>
9-
<h1>Hello World</h1>
9+
<h1>Hello World?</h1>
1010
</body>
1111
</html>

src/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ import './index.css';
33

44
const courseValue = numeral(1000).format('$0,0.00');
55
console.log(`I would like to pay ${courseValue} for this awesome course!`);
6-

src/index.test.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { expect } from 'chai';
2+
3+
const jsdom = require('jsdom');
4+
5+
const { JSDOM } = jsdom;
6+
import fs from 'fs';
7+
8+
describe('Our first test', () => {
9+
it('should pass', () => {
10+
expect(true).to.equal(true);
11+
});
12+
});
13+
14+
describe('index.html', () => {
15+
it('should say hello', () => {
16+
const index = fs.readFileSync('./src/index.html', 'utf-8');
17+
const dom = new JSDOM(index);
18+
const h1 = dom.window.document.querySelector('h1').textContent;
19+
expect(h1).to.equal('Hello World');
20+
});
21+
});

0 commit comments

Comments
 (0)