File tree 4 files changed +47
-0
lines changed
4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Browser Example
2
+
3
+ See full documentation about [ running Mocha in the browser] ( https://mochajs.org/#running-mocha-in-the-browser ) .
4
+
5
+ After ` npm install ` , open ` index.html ` in a browser.
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="utf-8 " />
5
+ < title > Mocha Tests</ title >
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7
+ < link rel ="stylesheet " href ="node_modules/mocha/mocha.css " />
8
+ </ head >
9
+ < body >
10
+ < div id ="mocha "> </ div >
11
+
12
+ < script src ="node_modules/chai/chai.js "> </ script >
13
+ < script src ="node_modules/mocha/mocha.js "> </ script >
14
+
15
+ < script class ="mocha-init ">
16
+ mocha . setup ( "bdd" ) ;
17
+ mocha . checkLeaks ( ) ;
18
+ </ script >
19
+ < script src ="test.example.js "> </ script >
20
+ < script class ="mocha-exec ">
21
+ mocha . run ( ) ;
22
+ </ script >
23
+ </ body >
24
+ </ html >
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " example-browser" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " Browser example" ,
5
+ "engines" : {
6
+ "node" : " >=10.0.0"
7
+ },
8
+ "license" : " ISC" ,
9
+ "devDependencies" : {
10
+ "chai" : " ^4.4.1" ,
11
+ "mocha" : " latest"
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ describe ( "example" , ( ) => {
2
+ it ( "2 + 2" , ( ) => {
3
+ chai . expect ( 2 + 2 ) . to . be . eql ( 4 ) ;
4
+ } ) ;
5
+ } ) ;
You can’t perform that action at this time.
0 commit comments