node/test/parallel/test-runner-extraneous-async-activity.js
Moshe Atlow d1eaded0d1
test_runner: count nested tests
PR-URL: https://github.com/nodejs/node/pull/47094
Fixes: https://github.com/nodejs/node/issues/46762
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2023-03-21 08:16:38 +00:00

34 lines
1.2 KiB
JavaScript

'use strict';
require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const { spawnSync } = require('child_process');
{
const child = spawnSync(process.execPath, [
'--test',
fixtures.path('test-runner', 'extraneous_set_immediate_async.mjs'),
]);
const stdout = child.stdout.toString();
assert.match(stdout, /^# Warning: Test "extraneous async activity test" generated asynchronous activity after the test ended/m);
assert.match(stdout, /^# pass 1/m);
assert.match(stdout, /^# fail 1$/m);
assert.match(stdout, /^# cancelled 0$/m);
assert.strictEqual(child.status, 1);
assert.strictEqual(child.signal, null);
}
{
const child = spawnSync(process.execPath, [
'--test',
fixtures.path('test-runner', 'extraneous_set_timeout_async.mjs'),
]);
const stdout = child.stdout.toString();
assert.match(stdout, /^# Warning: Test "extraneous async activity test" generated asynchronous activity after the test ended/m);
assert.match(stdout, /^# pass 1$/m);
assert.match(stdout, /^# fail 1$/m);
assert.match(stdout, /^# cancelled 0$/m);
assert.strictEqual(child.status, 1);
assert.strictEqual(child.signal, null);
}