Skip to content

Commit 1388650

Browse files
committed
test: fix linting and remove unnecessary space changes
to make the changes clear, remove unnecessary space changes Fixes: #60815
1 parent a290baf commit 1388650

8 files changed

+160
-184
lines changed

test/es-module/test-esm-detect-ambiguous.mjs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,16 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL },
264264
});
265265

266266
it('still throws on `await` in an ordinary sync function', async () => {
267-
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
268-
'--eval',
269-
'function fn() { await Promise.resolve(); } fn();',
270-
]);
267+
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
268+
'--eval',
269+
'function fn() { await Promise.resolve(); } fn();',
270+
]);
271271

272-
assert.match(stderr, /SyntaxError: await is only valid in async function/);
273-
assert.strictEqual(stdout, '');
274-
assert.strictEqual(code, 1);
275-
assert.strictEqual(signal, null);
276-
});
272+
assert.match(stderr, /SyntaxError: await is only valid in async function/);
273+
assert.strictEqual(stdout, '');
274+
assert.strictEqual(code, 1);
275+
assert.strictEqual(signal, null);
276+
});
277277

278278
it('throws on undefined `require` when top-level `await` triggers ESM parsing', async () => {
279279
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
@@ -315,16 +315,16 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL },
315315
});
316316

317317
it('still throws on double `const` declaration not at the top level', async () => {
318-
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
319-
'--eval',
320-
'function fn() { const require = 1; const require = 2; } fn();',
321-
]);
322-
323-
assert.match(stderr, /SyntaxError: Identifier 'require' has already been declared/);
324-
assert.strictEqual(stdout, '');
325-
assert.strictEqual(code, 1);
326-
assert.strictEqual(signal, null);
327-
});
318+
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
319+
'--eval',
320+
'function fn() { const require = 1; const require = 2; } fn();',
321+
]);
322+
323+
assert.match(stderr, /SyntaxError: Identifier 'require' has already been declared/);
324+
assert.strictEqual(stdout, '');
325+
assert.strictEqual(code, 1);
326+
assert.strictEqual(signal, null);
327+
});
328328
});
329329

330330
describe('warn about typeless packages for .js files with ESM syntax', { concurrency: true }, () => {

test/es-module/test-esm-import-meta-main-eval.mjs

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -100,39 +100,35 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat
100100
});
101101
});
102102

103-
it('should evaluate true in worker instantiated with module source by evaluated script',
104-
onlyWithAmaro,
105-
async () => {
106-
const result = await spawnPromisified(
107-
process.execPath,
108-
['--input-type=module-typescript',
109-
'--disable-warning=ExperimentalWarning',
110-
'--eval',
111-
wrapScriptInEvalWorker(importMetaMainTSScript)],
112-
);
113-
assert.deepStrictEqual(result, {
114-
stderr: '',
115-
stdout: '',
116-
code: 0,
117-
signal: null,
118-
});
119-
});
120-
121-
it('should evaluate true in worker instantiated with `data:` URL by evaluated script',
122-
onlyWithAmaro,
123-
async () => {
124-
const result = await spawnPromisified(
125-
process.execPath,
126-
['--input-type=module',
127-
'--input-type=module-typescript',
128-
'--disable-warning=ExperimentalWarning',
129-
'--eval', wrapScriptInUrlWorker(importMetaMainTSScript)],
130-
);
131-
assert.deepStrictEqual(result, {
132-
stderr: '',
133-
stdout: '',
134-
code: 0,
135-
signal: null,
136-
});
137-
});
103+
it('should evaluate true in worker instantiated with module source by evaluated script', onlyWithAmaro, async () => {
104+
const result = await spawnPromisified(
105+
process.execPath,
106+
['--input-type=module-typescript',
107+
'--disable-warning=ExperimentalWarning',
108+
'--eval',
109+
wrapScriptInEvalWorker(importMetaMainTSScript)],
110+
);
111+
assert.deepStrictEqual(result, {
112+
stderr: '',
113+
stdout: '',
114+
code: 0,
115+
signal: null,
116+
});
117+
});
118+
119+
it('should evaluate true in worker instantiated with `data:` URL by evaluated script', onlyWithAmaro, async () => {
120+
const result = await spawnPromisified(
121+
process.execPath,
122+
['--input-type=module',
123+
'--input-type=module-typescript',
124+
'--disable-warning=ExperimentalWarning',
125+
'--eval', wrapScriptInUrlWorker(importMetaMainTSScript)],
126+
);
127+
assert.deepStrictEqual(result, {
128+
stderr: '',
129+
stdout: '',
130+
code: 0,
131+
signal: null,
132+
});
133+
});
138134
});

test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,29 @@ describe('unusual top-level await syntax errors', () => {
5050
});
5151

5252
it('should throw the error for unrelated syntax errors', async () => {
53-
const expression = 'foo bar';
54-
const wrapperExpressions = [
55-
[`function callSyntaxError() {}; callSyntaxError(${expression});`, /missing \) after argument list/],
56-
[`if (${expression}) {}`, /Unexpected identifier/],
57-
[`{ key: ${expression} }`, /Unexpected identifier/],
58-
[`[${expression}]`, /Unexpected identifier/],
59-
[`(${expression})`, /Unexpected identifier/],
60-
[`const ${expression} = 1;`, /Missing initializer in const declaration/],
61-
[`console.log('PI: ' Math.PI);`, /missing \) after argument list/],
62-
[`callAwait(await "" "");`, /missing \) after argument list/],
63-
];
53+
const expression = 'foo bar';
54+
const wrapperExpressions = [
55+
[`function callSyntaxError() {}; callSyntaxError(${expression});`, /missing \) after argument list/],
56+
[`if (${expression}) {}`, /Unexpected identifier/],
57+
[`{ key: ${expression} }`, /Unexpected identifier/],
58+
[`[${expression}]`, /Unexpected identifier/],
59+
[`(${expression})`, /Unexpected identifier/],
60+
[`const ${expression} = 1;`, /Missing initializer in const declaration/],
61+
[`console.log('PI: ' Math.PI);`, /missing \) after argument list/],
62+
[`callAwait(await "" "");`, /missing \) after argument list/],
63+
];
6464

65-
for (const [wrapperExpression, error] of wrapperExpressions) {
66-
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
67-
'--eval',
68-
`
69-
${wrapperExpression}
70-
`,
71-
]);
72-
assert.match(stderr, error);
73-
assert.strictEqual(stdout, '');
74-
assert.strictEqual(code, 1);
75-
assert.strictEqual(signal, null);
76-
}
77-
});
65+
for (const [wrapperExpression, error] of wrapperExpressions) {
66+
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
67+
'--eval',
68+
`
69+
${wrapperExpression}
70+
`,
71+
]);
72+
assert.match(stderr, error);
73+
assert.strictEqual(stdout, '');
74+
assert.strictEqual(code, 1);
75+
assert.strictEqual(signal, null);
76+
}
77+
});
7878
});

test/parallel/test-compile-cache-typescript-esm.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
// This tests NODE_COMPILE_CACHE works for ESM with types.
44

5-
const common = require('../common');
6-
if (!process.config.variables.node_use_amaro) {
7-
common.skip('Requires Amaro');
8-
}
5+
require('../common');
96
const { spawnSyncAndAssert } = require('../common/child_process');
107
const assert = require('assert');
118
const tmpdir = require('../common/tmpdir');

test/parallel/test-runner-global-setup-teardown.mjs

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -258,37 +258,35 @@ async function runTest(
258258
'Teardown should not run after setup fails');
259259
});
260260

261-
it('should run TypeScript globalSetup and globalTeardown functions',
262-
onlyWithAmaro,
263-
async () => {
264-
const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp');
265-
const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp');
261+
it('should run TypeScript globalSetup and globalTeardown functions', onlyWithAmaro, async () => {
262+
const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp');
263+
const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp');
266264

267-
const { stdout, stderr } = await runTest({
268-
isolation,
269-
globalSetupFile: 'basic-setup-teardown.ts',
270-
env: {
271-
SETUP_FLAG_PATH: setupFlagPath,
272-
TEARDOWN_FLAG_PATH: teardownFlagPath
273-
},
274-
additionalFlags: ['--no-warnings'],
275-
runnerEnabled
276-
});
265+
const { stdout, stderr } = await runTest({
266+
isolation,
267+
globalSetupFile: 'basic-setup-teardown.ts',
268+
env: {
269+
SETUP_FLAG_PATH: setupFlagPath,
270+
TEARDOWN_FLAG_PATH: teardownFlagPath
271+
},
272+
additionalFlags: ['--no-warnings'],
273+
runnerEnabled
274+
});
277275

278-
assert.match(stdout, /pass 2/);
279-
assert.match(stdout, /fail 0/);
280-
assert.match(stdout, /Global setup executed/);
281-
assert.match(stdout, /Global teardown executed/);
282-
assert.strictEqual(stderr.length, 0);
283-
284-
// After all tests complete, the teardown should have run
285-
assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist');
286-
const content = fs.readFileSync(teardownFlagPath, 'utf8');
287-
assert.strictEqual(content, 'Teardown was executed');
288-
289-
// Setup flag should have been removed by teardown
290-
assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed');
291-
});
276+
assert.match(stdout, /pass 2/);
277+
assert.match(stdout, /fail 0/);
278+
assert.match(stdout, /Global setup executed/);
279+
assert.match(stdout, /Global teardown executed/);
280+
assert.strictEqual(stderr.length, 0);
281+
282+
// After all tests complete, the teardown should have run
283+
assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist');
284+
const content = fs.readFileSync(teardownFlagPath, 'utf8');
285+
assert.strictEqual(content, 'Teardown was executed');
286+
287+
// Setup flag should have been removed by teardown
288+
assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed');
289+
});
292290

293291
it('should run ESM globalSetup and globalTeardown functions', async () => {
294292
const setupFlagPath = tmpdir.resolve('setup-executed-esm.tmp');

test/parallel/test-runner-run-global-hooks.mjs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mustCall, mustCallAtLeast, skip } from '../common/index.mjs';
1+
import { mustCall, mustCallAtLeast } from '../common/index.mjs';
22
import * as fixtures from '../common/fixtures.mjs';
33
import { describe, it, beforeEach, run } from 'node:test';
44
import assert from 'node:assert';
@@ -8,9 +8,7 @@ import path from 'node:path';
88
import { spawn } from 'node:child_process';
99
import { once } from 'node:events';
1010

11-
if (!process.config.variables.node_use_amaro) {
12-
skip('Requires Amaro');
13-
}
11+
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };
1412

1513
const testFixtures = fixtures.path('test-runner', 'global-setup-teardown');
1614
const runnerFixture = fixtures.path('test-runner', 'test-runner-global-hooks.mjs');
@@ -166,31 +164,29 @@ describe('require(\'node:test\').run with global hooks', { concurrency: false },
166164
assert.strictEqual(content, 'Setup part, Teardown part');
167165
});
168166

169-
it('should run TypeScript globalSetup and globalTeardown functions',
170-
onlyWithAmaro,
171-
async () => {
172-
const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp');
173-
const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp');
174-
175-
const { results } = await runTestWithGlobalHooks({
176-
globalSetupFile: 'basic-setup-teardown.ts',
177-
runnerEnv: {
178-
SETUP_FLAG_PATH: setupFlagPath,
179-
TEARDOWN_FLAG_PATH: teardownFlagPath
180-
},
181-
isolation
182-
});
183-
184-
assert.strictEqual(results.passed, 2);
185-
assert.strictEqual(results.failed, 0);
186-
// After all tests complete, the teardown should have run
187-
assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist');
188-
const content = fs.readFileSync(teardownFlagPath, 'utf8');
189-
assert.strictEqual(content, 'Teardown was executed');
190-
191-
// Setup flag should have been removed by teardown
192-
assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed');
193-
});
167+
it('should run TypeScript globalSetup and globalTeardown functions', onlyWithAmaro, async () => {
168+
const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp');
169+
const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp');
170+
171+
const { results } = await runTestWithGlobalHooks({
172+
globalSetupFile: 'basic-setup-teardown.ts',
173+
runnerEnv: {
174+
SETUP_FLAG_PATH: setupFlagPath,
175+
TEARDOWN_FLAG_PATH: teardownFlagPath
176+
},
177+
isolation
178+
});
179+
180+
assert.strictEqual(results.passed, 2);
181+
assert.strictEqual(results.failed, 0);
182+
// After all tests complete, the teardown should have run
183+
assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist');
184+
const content = fs.readFileSync(teardownFlagPath, 'utf8');
185+
assert.strictEqual(content, 'Teardown was executed');
186+
187+
// Setup flag should have been removed by teardown
188+
assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed');
189+
});
194190

195191
it('should run ESM globalSetup and globalTeardown functions', async () => {
196192
const setupFlagPath = tmpdir.resolve('setup-executed-esm.tmp');

0 commit comments

Comments
 (0)