Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
tools: enable linter in test/fixtures/test-runner/output
  • Loading branch information
aduh95 committed Apr 1, 2025
commit 3dbab322aa0e359375718f625dddc1242974aa46
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export default [
// We want to lint only a few specific fixtures folders
'test/fixtures/*',
'!test/fixtures/console',
'!test/fixtures/test-runner',
'test/fixtures/test-runner/*',
'!test/fixtures/test-runner/output',
'!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
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
@@ -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
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
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
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
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
@@ -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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
12 changes: 6 additions & 6 deletions test/fixtures/test-runner/output/hooks-with-no-global-test.js
Original file line number Diff line number Diff line change
@@ -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 = [];
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('describe hooks with no global tests', () => {
before(() => {
testArr.push('describe before');
});
after(()=> {
after(() => {
testArr.push('describe after');
});
beforeEach(() => {
Expand All @@ -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'));
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/test-runner/output/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +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',
'beforeEach nested 2', 'nested beforeEach nested 2', 'nested 2', 'nested afterEach nested 2', 'afterEach nested 2',
'beforeEach nested 2', 'nested beforeEach nested 2', 'nested2', 'nested afterEach nested 2', 'afterEach nested 2',
'afterEach nested',
'nested after nested',
'after test hooks',
Expand Down Expand Up @@ -228,7 +228,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) => {
Expand All @@ -247,9 +247,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', () => {});
});

Expand Down
6 changes: 5 additions & 1 deletion test/fixtures/test-runner/output/junit_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Loading