mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
tools: enable linter in test/fixtures/test-runner/output
PR-URL: https://github.com/nodejs/node/pull/57698 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
This commit is contained in:
1 parent
9f1ad3c6da
commit
bbbf49812e
45 files changed
+178
-112
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { readdirSync } from 'node:fs';
|
||||
import Module from 'node:module';
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
|
||||
@@ -25,6 +26,12 @@ const { default: stylisticJs } = await importEslintTool('@stylistic/eslint-plugi
|
||||
|
||||
nodeCore.RULES_DIR = fileURLToPath(new URL('./tools/eslint-rules', import.meta.url));
|
||||
|
||||
function filterFilesInDir(dirpath, filterFn) {
|
||||
return readdirSync(dirpath)
|
||||
.filter(filterFn)
|
||||
.map((f) => `${dirpath}/${f}`);
|
||||
}
|
||||
|
||||
// The Module._resolveFilename() monkeypatching is to make it so that ESLint is able to
|
||||
// dynamically load extra modules that we install with it.
|
||||
const ModuleResolveFilename = Module._resolveFilename;
|
||||
@@ -54,6 +61,14 @@ export default [
|
||||
'test/fixtures/*',
|
||||
'!test/fixtures/console',
|
||||
'!test/fixtures/eval',
|
||||
'!test/fixtures/test-runner',
|
||||
'test/fixtures/test-runner/*',
|
||||
'!test/fixtures/test-runner/output',
|
||||
...filterFilesInDir(
|
||||
'test/fixtures/test-runner/output',
|
||||
// Filtering tsc output files (i.e. if there a foo.ts, we ignore foo.js):
|
||||
(f, _, files) => f.endsWith('js') && files.includes(f.replace(/\.[cm]?js$/, '.ts')),
|
||||
),
|
||||
'!test/fixtures/v8',
|
||||
'!test/fixtures/vm',
|
||||
]),
|
||||
|
||||
+8
-8
@@ -5,8 +5,8 @@ describe('1 before describe', () => {
|
||||
const ac = new AbortController();
|
||||
before(() => {
|
||||
console.log('before');
|
||||
ac.abort()
|
||||
}, {signal: ac.signal});
|
||||
ac.abort();
|
||||
}, { signal: ac.signal });
|
||||
|
||||
it('test 1', () => {
|
||||
console.log('1.1');
|
||||
@@ -20,8 +20,8 @@ describe('2 after describe', () => {
|
||||
const ac = new AbortController();
|
||||
after(() => {
|
||||
console.log('after');
|
||||
ac.abort()
|
||||
}, {signal: ac.signal});
|
||||
ac.abort();
|
||||
}, { signal: ac.signal });
|
||||
|
||||
it('test 1', () => {
|
||||
console.log('2.1');
|
||||
@@ -35,8 +35,8 @@ describe('3 beforeEach describe', () => {
|
||||
const ac = new AbortController();
|
||||
beforeEach(() => {
|
||||
console.log('beforeEach');
|
||||
ac.abort()
|
||||
}, {signal: ac.signal});
|
||||
ac.abort();
|
||||
}, { signal: ac.signal });
|
||||
|
||||
it('test 1', () => {
|
||||
console.log('3.1');
|
||||
@@ -50,8 +50,8 @@ describe('4 afterEach describe', () => {
|
||||
const ac = new AbortController();
|
||||
afterEach(() => {
|
||||
console.log('afterEach');
|
||||
ac.abort()
|
||||
}, {signal: ac.signal});
|
||||
ac.abort();
|
||||
}, { signal: ac.signal });
|
||||
|
||||
it('test 1', () => {
|
||||
console.log('4.1');
|
||||
|
||||
@@ -8,5 +8,8 @@ const fixtures = require('../../../common/fixtures');
|
||||
const test = fixtures.path('test-runner/output/arbitrary-output-colored-1.js');
|
||||
const reset = fixtures.path('test-runner/output/reset-color-depth.js');
|
||||
await once(spawn(process.execPath, ['-r', reset, '--test', test], { stdio: 'inherit' }), 'exit');
|
||||
await once(spawn(process.execPath, ['-r', reset, '--test', '--test-reporter', 'tap', test], { stdio: 'inherit' }), 'exit');
|
||||
await once(
|
||||
spawn(process.execPath, ['-r', reset, '--test', '--test-reporter', 'tap', test], { stdio: 'inherit' }),
|
||||
'exit',
|
||||
);
|
||||
})().then(common.mustCall());
|
||||
+9
-6
@@ -5,16 +5,19 @@ const v8_reporter = require('internal/test_runner/reporter/v8-serializer');
|
||||
const { Buffer } = require('buffer');
|
||||
|
||||
|
||||
(async function () {
|
||||
// eslint-disable-next-line node-core/async-iife-no-unused-result
|
||||
(async function() {
|
||||
const reported = v8_reporter([
|
||||
{ type: "test:pass", data: { name: "test", nesting: 0, file: __filename, testNumber: 1, details: { duration_ms: 0 } } }
|
||||
{
|
||||
type: 'test:pass',
|
||||
data: { name: 'test', nesting: 0, file: __filename, testNumber: 1, details: { duration_ms: 0 } },
|
||||
},
|
||||
]);
|
||||
|
||||
for await (const chunk of reported) {
|
||||
process.stdout.write(chunk);
|
||||
process.stdout.write(Buffer.concat([Buffer.from("arbitrary - pre"), chunk]));
|
||||
process.stdout.write(Buffer.from("arbitrary - mid"));
|
||||
process.stdout.write(Buffer.concat([chunk, Buffer.from("arbitrary - post")]));
|
||||
process.stdout.write(Buffer.concat([Buffer.from('arbitrary - pre'), chunk]));
|
||||
process.stdout.write(Buffer.from('arbitrary - mid'));
|
||||
process.stdout.write(Buffer.concat([chunk, Buffer.from('arbitrary - post')]));
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
|
||||
test('failing assertion', () => {
|
||||
assert.strictEqual('!Hello World', 'Hello World!')
|
||||
})
|
||||
assert.strictEqual('!Hello World', 'Hello World!');
|
||||
});
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
const { beforeEach, afterEach, test} = require("node:test");
|
||||
const { beforeEach, afterEach, test } = require('node:test');
|
||||
beforeEach(() => {});
|
||||
afterEach(() => {});
|
||||
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
const { beforeEach, afterEach, test} = require("node:test");
|
||||
beforeEach(() => {}, {timeout: 10000});
|
||||
afterEach(() => {}, {timeout: 10000});
|
||||
const { beforeEach, afterEach, test } = require('node:test');
|
||||
beforeEach(() => {}, { timeout: 10000 });
|
||||
afterEach(() => {}, { timeout: 10000 });
|
||||
|
||||
for (let i = 1; i <= 11; ++i) {
|
||||
test(`${i}`, () => {});
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as c from '../coverage-snap/many-uncovered-lines.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
+1
-1
@@ -28,6 +28,6 @@ ok 1 - Coverage Print Fixed Width 100
|
||||
# output | | | |
|
||||
# coverage-width-100-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# all files | 52.80 | 60.00 | 1.61 |
|
||||
# all files | 53.13 | 60.00 | 1.61 |
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# end of coverage report
|
||||
@@ -1,7 +1,9 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
@@ -27,6 +27,6 @@ ok 1 - Coverage Print Fixed Width 100
|
||||
# output | | | |
|
||||
# coverage-width-100.mjs | 100.00 | 100.00 | 100.00 |
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# all files | 60.81 | 100.00 | 0.00 |
|
||||
# all files | 61.84 | 100.00 | 0.00 |
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# end of coverage report
|
||||
@@ -1,8 +1,11 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as c from '../coverage-snap/many-uncovered-lines.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
+1
-1
@@ -28,6 +28,6 @@ ok 1 - Coverage Print Fixed Width 150
|
||||
# output | | | |
|
||||
# coverage-width-150-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# all files | 52.80 | 60.00 | 1.61 |
|
||||
# all files | 53.13 | 60.00 | 1.61 |
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# end of coverage report
|
||||
@@ -1,7 +1,9 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
@@ -27,6 +27,6 @@ ok 1 - Coverage Print Fixed Width 150
|
||||
# output | | | |
|
||||
# coverage-width-150.mjs | 100.00 | 100.00 | 100.00 |
|
||||
# --------------------------------------------------------------------------------------------------------
|
||||
# all files | 60.81 | 100.00 | 0.00 |
|
||||
# all files | 61.84 | 100.00 | 0.00 |
|
||||
# --------------------------------------------------------------------------------------------------------
|
||||
# end of coverage report
|
||||
@@ -1,8 +1,11 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as c from '../coverage-snap/a-very-long-long-long-sub-dir/c.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
@@ -29,6 +29,6 @@ ok 1 - Coverage Print Fixed Width 40
|
||||
# output | | | |
|
||||
# …e-width-40.mjs | 100.00 | 100.00 | 100.00 |
|
||||
# --------------------------------------
|
||||
# all files | 59.06 | 100.00 | 0.00 |
|
||||
# all files | 60.00 | 100.00 | 0.00 |
|
||||
# --------------------------------------
|
||||
# end of coverage report
|
||||
@@ -1,7 +1,9 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as c from '../coverage-snap/many-uncovered-lines.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as c from '../coverage-snap/many-uncovered-lines.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
+1
-1
@@ -28,6 +28,6 @@ ok 1 - Coverage Print Fixed Width 100
|
||||
# output | | | |
|
||||
# coverage-width-80-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# all files | 52.80 | 60.00 | 1.61 |
|
||||
# all files | 53.13 | 60.00 | 1.61 |
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# end of coverage report
|
||||
@@ -1,7 +1,9 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
@@ -27,6 +27,6 @@ ok 1 - Coverage Print Fixed Width 80
|
||||
# output | | | |
|
||||
# coverage-width-80.mjs | 100.00 | 100.00 | 100.00 |
|
||||
# ------------------------------------------------------------------------------
|
||||
# all files | 60.81 | 100.00 | 0.00 |
|
||||
# all files | 61.84 | 100.00 | 0.00 |
|
||||
# ------------------------------------------------------------------------------
|
||||
# end of coverage report
|
||||
@@ -1,8 +1,11 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as c from '../coverage-snap/many-uncovered-lines.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
+1
-1
@@ -28,6 +28,6 @@ ok 1 - Coverage Print Fixed Width Infinity
|
||||
# output | | | |
|
||||
# coverage-width-infinity-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
|
||||
# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# all files | 52.80 | 60.00 | 1.61 |
|
||||
# all files | 53.13 | 60.00 | 1.61 |
|
||||
# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# end of coverage report
|
||||
@@ -1,7 +1,9 @@
|
||||
// Flags: --experimental-test-coverage
|
||||
// here we can't import common module as the coverage will be different based on the system
|
||||
// Unused imports are here in order to populate the coverage report
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as a from '../coverage-snap/b.js';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import * as b from '../coverage-snap/a.js';
|
||||
|
||||
import { test } from 'node:test';
|
||||
|
||||
@@ -27,6 +27,6 @@ ok 1 - Coverage Print Fixed Width Infinity
|
||||
# output | | | |
|
||||
# coverage-width-infinity.mjs | 100.00 | 100.00 | 100.00 |
|
||||
# -------------------------------------------------------------------------------------------------------------
|
||||
# all files | 60.81 | 100.00 | 0.00 |
|
||||
# all files | 61.84 | 100.00 | 0.00 |
|
||||
# -------------------------------------------------------------------------------------------------------------
|
||||
# end of coverage report
|
||||
@@ -10,4 +10,3 @@ mock.method(TestCoverage.prototype, 'summary', () => {
|
||||
});
|
||||
|
||||
test('ok');
|
||||
|
||||
+7
-7
@@ -311,7 +311,7 @@ describe('timeouts', () => {
|
||||
|
||||
it('timed out callback test', { timeout: 5 }, (t, done) => {
|
||||
setTimeout(() => {
|
||||
// Empty timer so the process doesn't exit before the timeout triggers.
|
||||
// Empty timer so the process doesn't exit before the timeout triggers.
|
||||
}, 5);
|
||||
setTimeout(done, 30_000_000).unref();
|
||||
});
|
||||
@@ -372,20 +372,20 @@ describe('rejected thenable', () => {
|
||||
};
|
||||
});
|
||||
|
||||
describe("async describe function", async () => {
|
||||
describe('async describe function', async () => {
|
||||
await null;
|
||||
|
||||
await it("it inside describe 1", async () => {
|
||||
await null
|
||||
await it('it inside describe 1', async () => {
|
||||
await null;
|
||||
});
|
||||
await it("it inside describe 2", async () => {
|
||||
await it('it inside describe 2', async () => {
|
||||
await null;
|
||||
});
|
||||
|
||||
describe("inner describe", async () => {
|
||||
describe('inner describe', async () => {
|
||||
await null;
|
||||
|
||||
it("it inside inner describe", async () => {
|
||||
it('it inside inner describe', async () => {
|
||||
await null;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ after(() => { console.log('with global after()'); });
|
||||
await Promise.resolve();
|
||||
|
||||
console.log('Execution order was:');
|
||||
const ll = (t) => { console.log(` * ${t.fullName}`) };
|
||||
const ll = (t) => { console.log(` * ${t.fullName}`); };
|
||||
|
||||
describe('A', () => {
|
||||
test.only('A', ll);
|
||||
|
||||
@@ -5,6 +5,7 @@ const { suite, test } = require('node:test');
|
||||
|
||||
suite('suite 1', () => {
|
||||
throw new Error('boom 1');
|
||||
// eslint-disable-next-line no-unreachable
|
||||
test('enabled - should not run', common.mustNotCall());
|
||||
});
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
const { it, after } = require('node:test');
|
||||
|
||||
after(() => {
|
||||
throw new Error('this should fail the test')
|
||||
throw new Error('this should fail the test');
|
||||
});
|
||||
|
||||
it('this is a test', () => {
|
||||
console.log('this is a test')
|
||||
console.log('this is a test');
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
const { test, describe, it, before, after, beforeEach, afterEach } = require('node:test');
|
||||
const assert = require("assert");
|
||||
const assert = require('assert');
|
||||
|
||||
// This file should not have any global tests to reproduce bug #48844
|
||||
const testArr = [];
|
||||
@@ -45,7 +45,7 @@ describe('describe hooks with no global tests', () => {
|
||||
before(() => {
|
||||
testArr.push('describe before');
|
||||
});
|
||||
after(()=> {
|
||||
after(() => {
|
||||
testArr.push('describe after');
|
||||
});
|
||||
beforeEach(() => {
|
||||
@@ -60,16 +60,16 @@ describe('describe hooks with no global tests', () => {
|
||||
|
||||
describe('nested', () => {
|
||||
before(() => {
|
||||
testArr.push('describe nested before')
|
||||
testArr.push('describe nested before');
|
||||
});
|
||||
after(() => {
|
||||
testArr.push('describe nested after')
|
||||
testArr.push('describe nested after');
|
||||
});
|
||||
beforeEach(() => {
|
||||
testArr.push('describe nested beforeEach')
|
||||
testArr.push('describe nested beforeEach');
|
||||
});
|
||||
afterEach(() => {
|
||||
testArr.push('describe nested afterEach')
|
||||
testArr.push('describe nested afterEach');
|
||||
});
|
||||
|
||||
it('nested 1', () => testArr.push('describe nested it 1'));
|
||||
|
||||
+4
-3
@@ -141,6 +141,7 @@ test('test hooks', async (t) => {
|
||||
'beforeEach nested',
|
||||
'nested before nested',
|
||||
'beforeEach nested 1', 'nested beforeEach nested 1', 'nested1', 'nested afterEach nested 1', 'afterEach nested 1',
|
||||
// eslint-disable-next-line @stylistic/js/max-len
|
||||
'beforeEach nested 2', 'nested beforeEach nested 2', 'nested 2', 'nested afterEach nested 2', 'afterEach nested 2',
|
||||
'afterEach nested',
|
||||
'nested after nested',
|
||||
@@ -228,7 +229,7 @@ test('afterEach context when test fails', async (t) => {
|
||||
assert.strictEqual(ctx.passed, false);
|
||||
assert.strictEqual(ctx.error, err);
|
||||
}));
|
||||
await t.test('1', () => { throw err });
|
||||
await t.test('1', () => { throw err; });
|
||||
});
|
||||
|
||||
test('afterEach throws and test fails', async (t) => {
|
||||
@@ -247,9 +248,9 @@ test('t.after() is called if test body throws', (t) => {
|
||||
|
||||
describe('run after when before throws', () => {
|
||||
after(common.mustCall(() => {
|
||||
console.log("- after() called")
|
||||
console.log('- after() called');
|
||||
}));
|
||||
before(() => { throw new Error('before')});
|
||||
before(() => { throw new Error('before'); });
|
||||
it('1', () => {});
|
||||
});
|
||||
|
||||
|
||||
+5
-1
@@ -4,4 +4,8 @@ const fixtures = require('../../../common/fixtures');
|
||||
const spawn = require('node:child_process').spawn;
|
||||
|
||||
spawn(process.execPath,
|
||||
['--no-warnings', '--test-reporter', 'junit', fixtures.path('test-runner/output/output.js')], { stdio: 'inherit' });
|
||||
[
|
||||
'--no-warnings', '--test-reporter', 'junit',
|
||||
fixtures.path('test-runner/output/output.js'),
|
||||
],
|
||||
{ stdio: 'inherit' });
|
||||
+7
-7
@@ -5,12 +5,12 @@ const spawn = require('node:child_process').spawn;
|
||||
|
||||
spawn(process.execPath,
|
||||
[
|
||||
'--no-warnings',
|
||||
'--experimental-test-coverage',
|
||||
'--test-coverage-exclude=!test/**',
|
||||
'--test-reporter',
|
||||
'lcov',
|
||||
fixtures.path('test-runner/output/output.js')
|
||||
'--no-warnings',
|
||||
'--experimental-test-coverage',
|
||||
'--test-coverage-exclude=!test/**',
|
||||
'--test-reporter',
|
||||
'lcov',
|
||||
fixtures.path('test-runner/output/output.js'),
|
||||
],
|
||||
{ stdio: 'inherit' }
|
||||
{ stdio: 'inherit' },
|
||||
);
|
||||
+3
-2
@@ -714,6 +714,7 @@ DA:402,1
|
||||
DA:403,1
|
||||
DA:404,1
|
||||
DA:405,1
|
||||
LH:403
|
||||
LF:405
|
||||
DA:406,1
|
||||
LH:404
|
||||
LF:406
|
||||
end_of_record
|
||||
+2
-2
@@ -82,8 +82,8 @@ describe('DescribeForMatchWithAncestors', () => {
|
||||
describe('NestedDescribeForMatchWithAncestors', () => {
|
||||
it('NestedTest', common.mustCall());
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('DescribeForMatchWithAncestors', () => {
|
||||
it('NestedTest', () => common.mustNotCall());
|
||||
})
|
||||
});
|
||||
+5
-3
@@ -26,7 +26,7 @@ test('only = true, with subtests', { only: true }, common.mustCall(async (t) =>
|
||||
// Switch the context to only execute 'only' tests.
|
||||
t.runOnly(true);
|
||||
await t.test('skipped subtest 1', common.mustNotCall());
|
||||
await t.test('skipped subtest 2'), common.mustNotCall();
|
||||
await t.test('skipped subtest 2', common.mustNotCall());
|
||||
await t.test('running subtest 3', { only: true }, common.mustCall());
|
||||
|
||||
// Switch the context back to execute all tests.
|
||||
@@ -56,6 +56,7 @@ describe.only('describe only = true, with subtests', common.mustCall(() => {
|
||||
describe.only('describe only = true, with a mixture of subtests', common.mustCall(() => {
|
||||
it.only('`it` subtest 1', common.mustCall());
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
it.only('`it` async subtest 1', common.mustCall(async () => {}));
|
||||
|
||||
it('`it` subtest 2 only=true', { only: true }, common.mustCall());
|
||||
@@ -68,6 +69,7 @@ describe.only('describe only = true, with a mixture of subtests', common.mustCal
|
||||
|
||||
test.only('`test` subtest 1', common.mustCall());
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
test.only('`test` async subtest 1', common.mustCall(async () => {}));
|
||||
|
||||
test('`test` subtest 2 only=true', { only: true }, common.mustCall());
|
||||
@@ -120,7 +122,7 @@ describe('describe only = false, with nested only subtests', { only: false }, co
|
||||
}));
|
||||
}));
|
||||
|
||||
test('nested tests with run only',{only: true}, common.mustCall(async (t) => {
|
||||
test('nested tests with run only', { only: true }, common.mustCall(async (t) => {
|
||||
// Within this test, all subtests are run by default.
|
||||
await t.test('running subtest - 1');
|
||||
|
||||
@@ -139,4 +141,4 @@ test('nested tests with run only',{only: true}, common.mustCall(async (t) => {
|
||||
// Explicitly do not run these tests.
|
||||
await t.test('skipped subtest - 7', { only: false }, common.mustNotCall());
|
||||
await t.test('skipped subtest - 8', { skip: true }, common.mustNotCall());
|
||||
}))
|
||||
}));
|
||||
+3
-2
@@ -395,9 +395,10 @@ test('assertion errors display actual and expected properly', async () => {
|
||||
number: 1,
|
||||
string: 'Hello',
|
||||
undefined: undefined,
|
||||
}
|
||||
};
|
||||
try {
|
||||
assert.deepEqual({ foo: 1, bar: 1, boo, baz }, { boo, baz, circular }); // eslint-disable-line no-restricted-properties
|
||||
// eslint-disable-next-line no-restricted-properties
|
||||
assert.deepEqual({ foo: 1, bar: 1, boo, baz }, { boo, baz, circular });
|
||||
} catch (err) {
|
||||
Error.stackTraceLimit = tmpLimit;
|
||||
throw err;
|
||||
|
||||
+5
-1
@@ -4,5 +4,9 @@ const fixtures = require('../../../common/fixtures');
|
||||
const spawn = require('node:child_process').spawn;
|
||||
|
||||
spawn(process.execPath,
|
||||
['--no-warnings', '--test', '--test-reporter', 'tap', fixtures.path('test-runner/output/output.js'), fixtures.path('test-runner/output/single.js')],
|
||||
[
|
||||
'--no-warnings', '--test', '--test-reporter', 'tap',
|
||||
fixtures.path('test-runner/output/output.js'),
|
||||
fixtures.path('test-runner/output/single.js'),
|
||||
],
|
||||
{ stdio: 'inherit' });
|
||||
+4
-1
@@ -4,7 +4,10 @@ const fixtures = require('../../../common/fixtures');
|
||||
const spawn = require('node:child_process').spawn;
|
||||
|
||||
const child = spawn(process.execPath,
|
||||
['--no-warnings', '--test', '--test-reporter', 'spec', fixtures.path('test-runner/output/output.js')],
|
||||
[
|
||||
'--no-warnings', '--test', '--test-reporter', 'spec',
|
||||
fixtures.path('test-runner/output/output.js'),
|
||||
],
|
||||
{ stdio: 'pipe' });
|
||||
// eslint-disable-next-line no-control-regex
|
||||
child.stdout.on('data', (d) => process.stdout.write(d.toString().replace(/[^\x00-\x7F]/g, '').replace(/\u001b\[\d+m/g, '')));
|
||||
|
||||
+36
-36
@@ -1,40 +1,40 @@
|
||||
'use strict';
|
||||
const { test, describe, it } = require('node:test');
|
||||
|
||||
describe('should NOT print --test-only diagnostic warning - describe-only-false', {only: false}, () => {
|
||||
it('only false in describe');
|
||||
describe('should NOT print --test-only diagnostic warning - describe-only-false', { only: false }, () => {
|
||||
it('only false in describe');
|
||||
});
|
||||
|
||||
describe('should NOT print --test-only diagnostic warning - it-only-false', () => {
|
||||
it('only false in the subtest', { only: false });
|
||||
});
|
||||
|
||||
describe('should NOT print --test-only diagnostic warning - no-only', () => {
|
||||
it('no only');
|
||||
});
|
||||
|
||||
test('should NOT print --test-only diagnostic warning - test-only-false', { only: false }, async (t) => {
|
||||
await t.test('only false in parent test');
|
||||
});
|
||||
|
||||
test('should NOT print --test-only diagnostic warning - t.test-only-false', async (t) => {
|
||||
await t.test('only false in subtest', { only: false });
|
||||
});
|
||||
|
||||
test('should NOT print --test-only diagnostic warning - no-only', async (t) => {
|
||||
await t.test('no only');
|
||||
});
|
||||
|
||||
test('should print --test-only diagnostic warning - test-only-true', { only: true }, async (t) => {
|
||||
await t.test('only true in parent test');
|
||||
});
|
||||
|
||||
test('should print --test-only diagnostic warning - t.test-only-true', async (t) => {
|
||||
await t.test('only true in subtest', { only: true });
|
||||
});
|
||||
|
||||
test('should print --test-only diagnostic warning - 2 levels of only', async (t) => {
|
||||
await t.test('only true in parent test', { only: false }, async (t) => {
|
||||
await t.test('only true in subtest', { only: true });
|
||||
});
|
||||
|
||||
describe('should NOT print --test-only diagnostic warning - it-only-false', () => {
|
||||
it('only false in the subtest', {only: false});
|
||||
});
|
||||
|
||||
describe('should NOT print --test-only diagnostic warning - no-only', () => {
|
||||
it('no only');
|
||||
});
|
||||
|
||||
test('should NOT print --test-only diagnostic warning - test-only-false', {only: false}, async (t) => {
|
||||
await t.test('only false in parent test');
|
||||
});
|
||||
|
||||
test('should NOT print --test-only diagnostic warning - t.test-only-false', async (t) => {
|
||||
await t.test('only false in subtest', {only: false});
|
||||
});
|
||||
|
||||
test('should NOT print --test-only diagnostic warning - no-only', async (t) => {
|
||||
await t.test('no only');
|
||||
});
|
||||
|
||||
test('should print --test-only diagnostic warning - test-only-true', {only: true}, async (t) => {
|
||||
await t.test('only true in parent test');
|
||||
})
|
||||
|
||||
test('should print --test-only diagnostic warning - t.test-only-true', async (t) => {
|
||||
await t.test('only true in subtest', {only: true});
|
||||
});
|
||||
|
||||
test('should print --test-only diagnostic warning - 2 levels of only', async (t) => {
|
||||
await t.test('only true in parent test', {only: false}, async (t) => {
|
||||
await t.test('only true in subtest', {only: true});
|
||||
});
|
||||
})
|
||||
});
|
||||
@@ -72,5 +72,5 @@ describe('planning with wait', () => {
|
||||
};
|
||||
|
||||
asyncActivity();
|
||||
})
|
||||
});
|
||||
});
|
||||
+5
-4
@@ -1,5 +1,6 @@
|
||||
const {describe, test, beforeEach, afterEach} = require("node:test");
|
||||
const {setTimeout} = require("timers/promises");
|
||||
'use strict';
|
||||
const { describe, test, beforeEach, afterEach } = require('node:test');
|
||||
const { setTimeout } = require('timers/promises');
|
||||
|
||||
|
||||
describe('before each timeout', () => {
|
||||
@@ -12,7 +13,7 @@ describe('before each timeout', () => {
|
||||
return;
|
||||
}
|
||||
console.log('not gonna timeout');
|
||||
}, {timeout: 500});
|
||||
}, { timeout: 500 });
|
||||
|
||||
test('first describe first test', () => {
|
||||
console.log('before each test first ' + i);
|
||||
@@ -34,7 +35,7 @@ describe('after each timeout', () => {
|
||||
return;
|
||||
}
|
||||
console.log('not gonna timeout');
|
||||
}, {timeout: 500});
|
||||
}, { timeout: 500 });
|
||||
|
||||
test('second describe first test', () => {
|
||||
console.log('after each test first ' + i);
|
||||
|
||||
Reference in new issue
Block a user