Skip to content

Commit

Permalink
feat: added browser example (#72)
Browse files Browse the repository at this point in the history
* feat: added browser example

* formatting

* fix: remove unnecessary script

* chore: delete package-lock.json
  • Loading branch information
JoshuaKGoldberg authored Jul 2, 2024
1 parent 161148e commit 1fd24ca
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/browser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Browser Example

See full documentation about [running Mocha in the browser](https://mochajs.org/#running-mocha-in-the-browser).

After `npm install`, open `index.html` in a browser.
24 changes: 24 additions & 0 deletions packages/browser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mocha Tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>

<script src="node_modules/chai/chai.js"></script>
<script src="node_modules/mocha/mocha.js"></script>

<script class="mocha-init">
mocha.setup("bdd");
mocha.checkLeaks();
</script>
<script src="test.example.js"></script>
<script class="mocha-exec">
mocha.run();
</script>
</body>
</html>
13 changes: 13 additions & 0 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "example-browser",
"version": "1.0.0",
"description": "Browser example",
"engines": {
"node": ">=10.0.0"
},
"license": "ISC",
"devDependencies": {
"chai": "^4.4.1",
"mocha": "latest"
}
}
5 changes: 5 additions & 0 deletions packages/browser/test.example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe("example", () => {
it("2 + 2", () => {
chai.expect(2 + 2).to.be.eql(4);
});
});

0 comments on commit 1fd24ca

Please sign in to comment.