mocha test cases in node js example
Mocha is a JavaScript test framework!
var assert = require('assert');
describe('Array', function () {
describe('#indexOf()', function () {
it('should return -1 when the value is not present', function () {
assert.equal([1, 2, 3].indexOf(4), -1);
});
});
});$ npm install --save mocha chai<!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="https://unpkg.com/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="https://unpkg.com/chai/chai.js"></script>
<script src="https://unpkg.com/mocha/mocha.js"></script>
<script class="mocha-init">
mocha.setup('bdd');
mocha.checkLeaks();
</script>
<script src="test.array.js"></script>
<script src="test.object.js"></script>
<script src="test.xhr.js"></script>
<script class="mocha-exec">
mocha.run();
</script>
</body>
</html>
Also in JavaScript:
- go to next route vuejs
- online javascript compiler
- how get height elemnt with that margin in js
- how to add google map in react js
- js dom ready function
- invalid left-hand side in assignment
- push a new route only triggers URL change but not location change
- js conditional object key
- javascript return object in arrow function
- create functional component react
- how to fill false into array javascript
- jsx-a11y/alt-text
- pull out only text from element javascript
- angular one way property binding
- how to check if item is in list js
- javascript get file extension from string
- You seem to not be depending on "@angular/core" and/or "rxjs". This is an error.
- angular 6 key value pair getvalue example
- js select option value when selected
- how to run nextjs in another port
- set up background process in express app
- how to go back one directory in git bash
- javascript check if text is overflowing
- javascript newline in alert