forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks-with-no-global-test.js
78 lines (65 loc) · 1.81 KB
/
hooks-with-no-global-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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const { test, describe, it, before, after, beforeEach, afterEach } = require('node:test');
const assert = require("assert");
// This file should not have any global tests to reproduce bug #48844
const testArr = [];
before(() => testArr.push('global before'));
after(() => {
testArr.push('global after');
assert.deepStrictEqual(testArr, [
'global before',
'describe before',
'describe beforeEach',
'describe it 1',
'describe afterEach',
'describe beforeEach',
'describe test 2',
'describe afterEach',
'describe nested before',
'describe beforeEach',
'describe nested beforeEach',
'describe nested it 1',
'describe afterEach',
'describe nested afterEach',
'describe beforeEach',
'describe nested beforeEach',
'describe nested test 2',
'describe afterEach',
'describe nested afterEach',
'describe nested after',
'describe after',
'global after',
]);
});
describe('describe hooks with no global tests', () => {
before(() => {
testArr.push('describe before');
});
after(()=> {
testArr.push('describe after');
});
beforeEach(() => {
testArr.push('describe beforeEach');
});
afterEach(() => {
testArr.push('describe afterEach');
});
it('1', () => testArr.push('describe it 1'));
test('2', () => testArr.push('describe test 2'));
describe('nested', () => {
before(() => {
testArr.push('describe nested before')
});
after(() => {
testArr.push('describe nested after')
});
beforeEach(() => {
testArr.push('describe nested beforeEach')
});
afterEach(() => {
testArr.push('describe nested afterEach')
});
it('nested 1', () => testArr.push('describe nested it 1'));
test('nested 2', () => testArr.push('describe nested test 2'));
});
});