-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
test.js
42 lines (34 loc) · 888 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Requiring module
const assert = require('assert');
// We can group similar tests inside a describe block
describe("Simple Calculations", () => {
before(() => {
console.log( "This part executes once before all tests" );
});
after(() => {
console.log( "This part executes once after all tests" );
});
// We can add nested blocks for different tests
describe( "Test1", () => {
beforeEach(() => {
console.log( "executes before every test" );
});
it("Is returning 5 when adding 2 + 3", () => {
assert.equal(2 + 3, 5);
});
it("Is returning 6 when multiplying 2 * 3", () => {
assert.equal(2*3, 6);
});
});
describe("Test2", () => {
beforeEach(() => {
console.log( "executes before every test" );
});
it("Is returning 4 when adding 2 + 3", () => {
assert.equal(2 + 3, 5);
});
it("Is returning 8 when multiplying 2 * 4", () => {
assert.equal(2*4, 8);
});
});
});