mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
bae14b7914
Our CI already run test files in parallel, having `node:test` spawns child processes concurrently could lead to oversubscribing the CI machine. This commit sets the `concurrency` depending on the presence of `TEST_PARALLEL` in the env, so running the test file individually still spawns child processes concurrently, and running the whole test suite does not oversubscribe the machine. PR-URL: https://github.com/nodejs/node/pull/52177 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
97 lines
3.1 KiB
JavaScript
97 lines
3.1 KiB
JavaScript
import { spawnPromisified } from '../common/index.mjs';
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
import { describe, it } from 'node:test';
|
|
import { match, strictEqual } from 'node:assert';
|
|
|
|
describe('--experimental-default-type=module should not support extension searching', {
|
|
concurrency: !process.env.TEST_PARALLEL,
|
|
}, () => {
|
|
it('should support extension searching under --experimental-default-type=commonjs', async () => {
|
|
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
|
|
'--experimental-default-type=commonjs',
|
|
'index',
|
|
], {
|
|
cwd: fixtures.path('es-modules/package-without-type'),
|
|
});
|
|
|
|
strictEqual(stdout, 'package-without-type\n');
|
|
strictEqual(stderr, '');
|
|
strictEqual(code, 0);
|
|
strictEqual(signal, null);
|
|
});
|
|
|
|
it('should error with implicit extension under --experimental-default-type=module', async () => {
|
|
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
|
|
'--experimental-default-type=module',
|
|
'index',
|
|
], {
|
|
cwd: fixtures.path('es-modules/package-without-type'),
|
|
});
|
|
|
|
match(stderr, /ENOENT.*Did you mean to import .*index\.js"\?/s);
|
|
strictEqual(stdout, '');
|
|
strictEqual(code, 1);
|
|
strictEqual(signal, null);
|
|
});
|
|
});
|
|
|
|
describe('--experimental-default-type=module should not parse paths as URLs', {
|
|
concurrency: !process.env.TEST_PARALLEL,
|
|
}, () => {
|
|
it('should not parse a `?` in a filename as starting a query string', async () => {
|
|
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
|
|
'--experimental-default-type=module',
|
|
'file#1.js',
|
|
], {
|
|
cwd: fixtures.path('es-modules/package-without-type'),
|
|
});
|
|
|
|
strictEqual(stderr, '');
|
|
strictEqual(stdout, 'file#1\n');
|
|
strictEqual(code, 0);
|
|
strictEqual(signal, null);
|
|
});
|
|
|
|
it('should resolve `..`', async () => {
|
|
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
|
|
'--experimental-default-type=module',
|
|
'../package-without-type/file#1.js',
|
|
], {
|
|
cwd: fixtures.path('es-modules/package-without-type'),
|
|
});
|
|
|
|
strictEqual(stderr, '');
|
|
strictEqual(stdout, 'file#1\n');
|
|
strictEqual(code, 0);
|
|
strictEqual(signal, null);
|
|
});
|
|
|
|
it('should allow a leading `./`', async () => {
|
|
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
|
|
'--experimental-default-type=module',
|
|
'./file#1.js',
|
|
], {
|
|
cwd: fixtures.path('es-modules/package-without-type'),
|
|
});
|
|
|
|
strictEqual(stderr, '');
|
|
strictEqual(stdout, 'file#1\n');
|
|
strictEqual(code, 0);
|
|
strictEqual(signal, null);
|
|
});
|
|
|
|
it('should not require a leading `./`', async () => {
|
|
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
|
|
'--experimental-default-type=module',
|
|
'file#1.js',
|
|
], {
|
|
cwd: fixtures.path('es-modules/package-without-type'),
|
|
});
|
|
|
|
strictEqual(stderr, '');
|
|
strictEqual(stdout, 'file#1\n');
|
|
strictEqual(code, 0);
|
|
strictEqual(signal, null);
|
|
});
|
|
});
|