• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const { before, beforeEach, describe, it, after, afterEach } = require('node:test');
3
4describe('1 before describe', () => {
5  const ac = new AbortController();
6  before(() => {
7    console.log('before');
8    ac.abort()
9  }, {signal: ac.signal});
10
11  it('test 1', () => {
12    console.log('1.1');
13  });
14  it('test 2', () => {
15    console.log('1.2');
16  });
17});
18
19describe('2 after describe', () => {
20  const ac = new AbortController();
21  after(() => {
22    console.log('after');
23    ac.abort()
24  }, {signal: ac.signal});
25
26  it('test 1', () => {
27    console.log('2.1');
28  });
29  it('test 2', () => {
30    console.log('2.2');
31  });
32});
33
34describe('3 beforeEach describe', () => {
35  const ac = new AbortController();
36  beforeEach(() => {
37    console.log('beforeEach');
38    ac.abort()
39  }, {signal: ac.signal});
40
41  it('test 1', () => {
42    console.log('3.1');
43  });
44  it('test 2', () => {
45    console.log('3.2');
46  });
47});
48
49describe('4 afterEach describe', () => {
50  const ac = new AbortController();
51  afterEach(() => {
52    console.log('afterEach');
53    ac.abort()
54  }, {signal: ac.signal});
55
56  it('test 1', () => {
57    console.log('4.1');
58  });
59  it('test 2', () => {
60    console.log('4.2');
61  });
62});
63