|
1 | | -import * as common from '../common/index.mjs'; |
| 1 | +import { spawnPromisified } from '../common/index.mjs'; |
2 | 2 | import * as fixtures from '../common/fixtures.mjs'; |
3 | 3 | import { spawn } from 'node:child_process'; |
4 | 4 | import { describe, it } from 'node:test'; |
5 | 5 | import assert from 'node:assert'; |
6 | 6 |
|
7 | | -if (!process.config.variables.node_use_amaro) { |
8 | | - common.skip('Requires Amaro'); |
9 | | -} |
10 | | -const { spawnPromisified } = common; |
11 | | - |
12 | 7 | describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, () => { |
13 | 8 | describe('string input', { concurrency: !process.env.TEST_PARALLEL }, () => { |
14 | 9 | it('permits ESM syntax in --eval input without requiring --input-type=module', async () => { |
@@ -268,17 +263,19 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, |
268 | 263 | assert.strictEqual(signal, null); |
269 | 264 | }); |
270 | 265 |
|
271 | | - it('still throws on `await` in an ordinary sync function', async () => { |
272 | | - const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ |
273 | | - '--eval', |
274 | | - 'function fn() { await Promise.resolve(); } fn();', |
275 | | - ]); |
| 266 | + it('still throws on `await` in an ordinary sync function', |
| 267 | + { skip: !process.config.variables.node_use_amaro }, |
| 268 | + async () => { |
| 269 | + const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ |
| 270 | + '--eval', |
| 271 | + 'function fn() { await Promise.resolve(); } fn();', |
| 272 | + ]); |
276 | 273 |
|
277 | | - assert.match(stderr, /SyntaxError: await is only valid in async function/); |
278 | | - assert.strictEqual(stdout, ''); |
279 | | - assert.strictEqual(code, 1); |
280 | | - assert.strictEqual(signal, null); |
281 | | - }); |
| 274 | + assert.match(stderr, /SyntaxError: await is only valid in async function/); |
| 275 | + assert.strictEqual(stdout, ''); |
| 276 | + assert.strictEqual(code, 1); |
| 277 | + assert.strictEqual(signal, null); |
| 278 | + }); |
282 | 279 |
|
283 | 280 | it('throws on undefined `require` when top-level `await` triggers ESM parsing', async () => { |
284 | 281 | const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ |
@@ -319,17 +316,19 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, |
319 | 316 | assert.strictEqual(signal, null); |
320 | 317 | }); |
321 | 318 |
|
322 | | - it('still throws on double `const` declaration not at the top level', async () => { |
323 | | - const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ |
324 | | - '--eval', |
325 | | - 'function fn() { const require = 1; const require = 2; } fn();', |
326 | | - ]); |
327 | | - |
328 | | - assert.match(stderr, /SyntaxError: Identifier 'require' has already been declared/); |
329 | | - assert.strictEqual(stdout, ''); |
330 | | - assert.strictEqual(code, 1); |
331 | | - assert.strictEqual(signal, null); |
332 | | - }); |
| 319 | + it('still throws on double `const` declaration not at the top level', |
| 320 | + { skip: !process.config.variables.node_use_amaro }, |
| 321 | + async () => { |
| 322 | + const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ |
| 323 | + '--eval', |
| 324 | + 'function fn() { const require = 1; const require = 2; } fn();', |
| 325 | + ]); |
| 326 | + |
| 327 | + assert.match(stderr, /SyntaxError: Identifier 'require' has already been declared/); |
| 328 | + assert.strictEqual(stdout, ''); |
| 329 | + assert.strictEqual(code, 1); |
| 330 | + assert.strictEqual(signal, null); |
| 331 | + }); |
333 | 332 | }); |
334 | 333 |
|
335 | 334 | describe('warn about typeless packages for .js files with ESM syntax', { concurrency: true }, () => { |
|
0 commit comments