Skip to content

Commit 1d9ace0

Browse files
committed
module 9 work in progress
1 parent 104b224 commit 1d9ace0

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
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"

buildScripts/testSetup.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() {};

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
"description": "JavaScript development environment Pluralsight course by Cory House",
55
"scripts": {
66
"prestart": "babel-node buildScripts/startMessage.js",
7-
"start": "npm-run-all --parallel security-check open:src lint:watch",
7+
"start": "npm-run-all --parallel security-check open:src lint:watch test:watch",
88
"open:src": "babel-node buildScripts/srcServer.js",
99
"lint": "esw webpack.config.*, src, buildScripts --color",
1010
"lint:watch": "npm run lint -- --watch",
1111
"security-check": "nsp check",
1212
"localtunnel": "lt --port 3000",
13-
"share": "npm-run-all --parallel open:src localtunnel"
13+
"share": "npm-run-all --parallel open:src localtunnel",
14+
"test": "mocha --reporter progress buildScripts/testSetup.js \"src/**/*.test.js\"",
15+
"test:watch": "npm run test -- --watch"
1416
},
1517
"author": "Cory House",
1618
"license": "MIT",

src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
</head>
66
<body>
7-
<h1>Hello World!</h1>
7+
<h1>Hello World?</h1>
88
<script src="bundle.js"></script>
99
</body>
1010
</html>

src/index.test.js

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

0 commit comments

Comments
 (0)