• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2require('../../../common');
3const { describe, it } = require('node:test');
4
5describe('describe timeout signal', { signal: AbortSignal.timeout(1) }, (t) => {
6  it('ok 1', async () => {});
7  it('ok 2', () => {});
8  it('ok 3', { signal: t.signal }, async () => {});
9  it('ok 4', { signal: t.signal }, () => {});
10  it('not ok 1', () => new Promise(() => {}));
11  it('not ok 2', (done) => {});
12  it('not ok 3', { signal: t.signal }, () => new Promise(() => {}));
13  it('not ok 4', { signal: t.signal }, (done) => {});
14  it('not ok 5', { signal: t.signal }, function(done) {
15    this.signal.addEventListener('abort', done);
16  });
17});
18
19describe('describe abort signal', { signal: AbortSignal.abort() }, () => {
20  it('should not appear', () => {});
21});
22
23// AbortSignal.timeout(1) doesn't prevent process from closing
24// thus we have to keep the process open to prevent cancelation
25// of the entire test tree
26setTimeout(() => {}, 1000);
27