Skip to content

tools: enable linter in test/fixtures/test-runner/output #57698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readdirSync } from 'node:fs';
import Module from 'node:module';
import { fileURLToPath, URL } from 'node:url';

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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',
]),
Expand Down
16 changes: 8 additions & 8 deletions test/fixtures/test-runner/output/abort_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand Down
5 changes: 4 additions & 1 deletion test/fixtures/test-runner/output/arbitrary-output-colored.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
15 changes: 9 additions & 6 deletions test/fixtures/test-runner/output/arbitrary-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')]));
}
})();

8 changes: 4 additions & 4 deletions test/fixtures/test-runner/output/assertion-color-tty.mjs
Original file line number Diff line number Diff line change
@@ -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!');
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const { beforeEach, afterEach, test} = require("node:test");
const { beforeEach, afterEach, test } = require('node:test');
beforeEach(() => {});
afterEach(() => {});

Expand Down
Original file line number Diff line number Diff line change
@@ -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}`, () => {});
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/coverage-width-100.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/coverage-width-150.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions test/fixtures/test-runner/output/coverage-width-40.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/coverage-width-80-color.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/coverage-width-80.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/fixtures/test-runner/output/coverage-width-infinity.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion test/fixtures/test-runner/output/coverage_failure.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ mock.method(TestCoverage.prototype, 'summary', () => {
});

test('ok');

14 changes: 7 additions & 7 deletions test/fixtures/test-runner/output/describe_it.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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;
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-runner/output/filtered-suite-order.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/test-runner/output/filtered-suite-throws.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});

Expand Down
Loading
Loading