File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change
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 ( ) { } ;
Original file line number Diff line number Diff line change 4
4
"description" : " JavaScript development environment Pluralsight course by Cory House" ,
5
5
"scripts" : {
6
6
"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 " ,
8
8
"open:src" : " babel-node buildScripts/srcServer.js" ,
9
9
"lint" : " esw webpack.config.* src buildScripts --color" ,
10
10
"lint:watch" : " npm run lint -- --watch" ,
11
11
"security-check" : " nsp check" ,
12
12
"localtunnel" : " lt --port 3000 --subdomain kevin" ,
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 test -- --watch"
14
16
},
15
17
"author" : " Cory House" ,
16
18
"license" : " MIT" ,
Original file line number Diff line number Diff line change
1
+ import { expect } from 'chai' ;
2
+ import jsdom from 'jsdom' ;
3
+ import fs from 'fs' ;
4
+
5
+ describe ( 'Our first test' , function ( ) {
6
+ it ( 'should pass' , function ( ) {
7
+ expect ( true ) . to . equal ( true ) ;
8
+ } ) ;
9
+ } ) ;
10
+
11
+ describe ( 'index.html' , function ( ) {
12
+ it ( 'should say hello' , function ( 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
+ } ) ;
You can’t perform that action at this time.
0 commit comments