Skip to content

Commit dba1738

Browse files
committed
Allow ESM imports in jest
1 parent 73df91c commit dba1738

5 files changed

Lines changed: 53 additions & 34 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"runtimeExecutable": null,
1212
"program": "${workspaceRoot}/scripts/debugTests.js",
1313
"cwd": "${fileDirname}",
14+
"runtimeArgs": ["--nolazy", "--inspect", "--experimental-vm-modules"],
1415
"args": ["--", "--runInBand", "--watch", "--testTimeout=1000000", "${file}"],
1516
"sourceMaps": true,
1617
"outputCapture": "std",
@@ -33,27 +34,6 @@
3334
"processId": "${command:PickProcess}",
3435
"sourceMaps": true,
3536
"skipFiles": ["<node_internals>/**"]
36-
},
37-
{
38-
// Debug configuration for Jest extension
39-
"name": "vscode-jest-tests.v2",
40-
"type": "node",
41-
"request": "launch",
42-
"runtimeExecutable": "npm",
43-
"cwd": "${workspaceFolder}",
44-
"runtimeArgs": ["run-script", "test"],
45-
"args": [
46-
"--",
47-
"--runInBand",
48-
"--watch",
49-
"--testTimeout=1000000",
50-
"--no-coverage",
51-
"--testNamePattern",
52-
"${jest.testNamePattern}",
53-
"--runTestsByPath",
54-
"${jest.testFile}"
55-
],
56-
"console": "integratedTerminal"
5737
}
5838
]
5939
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"type": "none",
5+
"comment": "Allow ESM imports in jest",
6+
"packageName": "beachball",
7+
"email": "elcraig@microsoft.com",
8+
"dependentChangeType": "none"
9+
}
10+
]
11+
}

packages/beachball/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
"depcheck": "yarn run -T depcheck .",
2727
"lint": "yarn run -T eslint --color --max-warnings=0 src",
2828
"start": "yarn run -T tsc -w --preserveWatchOutput",
29-
"test": "yarn run -T jest",
29+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' yarn run -T jest",
3030
"test:all": "yarn test:unit && yarn test:func && yarn test:e2e",
31-
"test:e2e": "yarn run -T jest --selectProjects e2e",
32-
"test:func": "yarn run -T jest --selectProjects functional",
33-
"test:unit": "yarn run -T jest --selectProjects unit",
34-
"test:watch": "yarn run -T jest --watch",
31+
"test:e2e": "yarn test --selectProjects e2e",
32+
"test:func": "yarn test --selectProjects functional",
33+
"test:unit": "yarn test --selectProjects unit",
34+
"test:watch": "yarn test --watch",
3535
"update-snapshots": "yarn test:unit -u && yarn test:func -u && yarn test:e2e -u"
3636
},
3737
"dependencies": {
@@ -55,7 +55,8 @@
5555
"@types/tmp": "^0.2.3",
5656
"@types/yargs-parser": "^21.0.0",
5757
"@verdaccio/types": "^13.0.0",
58-
"get-port": "^5.0.0",
58+
"cross-env": "^10.1.0",
59+
"get-port": "^7.0.0",
5960
"normalized-tmpdir": "1.0.1",
6061
"strip-ansi": "^6.0.1",
6162
"tmp": "^0.2.1",

packages/beachball/src/__fixtures__/registry.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { ConfigBuilder } from '@verdaccio/config';
22
import { fork, type ChildProcess } from 'child_process';
33
import execa from 'execa';
44
import fs from 'fs';
5-
import getPort from 'get-port';
65
import os from 'os';
76
import path from 'path';
87
import { removeTempDir, tmpdir } from './tmpdir';
@@ -58,7 +57,14 @@ export class Registry {
5857
// If this is consistently having problems, probably it's best to increase portRange.
5958
const maxPort = this.startPort + portRange;
6059
console.log(`Looking for free ports in range ${this.startPort} to ${maxPort}`);
61-
const tryPort = await getPort({ port: getPort.makeRange(this.startPort, maxPort) });
60+
61+
const port: number[] = [];
62+
for (let i = this.startPort; i <= maxPort; i++) {
63+
port.push(i);
64+
}
65+
66+
const getPort = await import('get-port');
67+
const tryPort = await getPort.default({ port });
6268

6369
// Try to start the server. If it fails, it's likely a config error or something where a retry
6470
// won't be helpful, so just let it throw.

yarn.lock

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,13 @@ __metadata:
435435
languageName: node
436436
linkType: hard
437437

438+
"@epic-web/invariant@npm:^1.0.0":
439+
version: 1.0.0
440+
resolution: "@epic-web/invariant@npm:1.0.0"
441+
checksum: 10c0/72dbeb026e4e4eb3bc9c65739b91408ca77ab7d603a2494fa2eff3790ec22892c4caba751cffdf30f5ccf0e7ba79c1e9c96cf0a357404b9432bf1365baac23ca
442+
languageName: node
443+
linkType: hard
444+
438445
"@eslint-community/eslint-utils@npm:^4.8.0, @eslint-community/eslint-utils@npm:^4.9.1":
439446
version: 4.9.1
440447
resolution: "@eslint-community/eslint-utils@npm:4.9.1"
@@ -2354,8 +2361,9 @@ __metadata:
23542361
"@vercel/detect-agent": "npm:^1.2.1"
23552362
"@verdaccio/types": "npm:^13.0.0"
23562363
cosmiconfig: "npm:^9.0.1"
2364+
cross-env: "npm:^10.1.0"
23572365
execa: "npm:^5.1.1"
2358-
get-port: "npm:^5.0.0"
2366+
get-port: "npm:^7.0.0"
23592367
minimatch: "npm:^3.1.5"
23602368
normalized-tmpdir: "npm:1.0.1"
23612369
p-graph: "npm:^1.3.0"
@@ -2855,6 +2863,19 @@ __metadata:
28552863
languageName: node
28562864
linkType: hard
28572865

2866+
"cross-env@npm:^10.1.0":
2867+
version: 10.1.0
2868+
resolution: "cross-env@npm:10.1.0"
2869+
dependencies:
2870+
"@epic-web/invariant": "npm:^1.0.0"
2871+
cross-spawn: "npm:^7.0.6"
2872+
bin:
2873+
cross-env: dist/bin/cross-env.js
2874+
cross-env-shell: dist/bin/cross-env-shell.js
2875+
checksum: 10c0/834a862db456ba1fedf6c6da43436b123ae38f514fa286d6f0937c14fa83f13469f77f70f2812db041ae2d84f82bac627040b8686030aca27fbdf113dfa38b63
2876+
languageName: node
2877+
linkType: hard
2878+
28582879
"cross-spawn@npm:^7.0.3, cross-spawn@npm:^7.0.6":
28592880
version: 7.0.6
28602881
resolution: "cross-spawn@npm:7.0.6"
@@ -3854,10 +3875,10 @@ __metadata:
38543875
languageName: node
38553876
linkType: hard
38563877

3857-
"get-port@npm:^5.0.0":
3858-
version: 5.1.1
3859-
resolution: "get-port@npm:5.1.1"
3860-
checksum: 10c0/2873877a469b24e6d5e0be490724a17edb39fafc795d1d662e7bea951ca649713b4a50117a473f9d162312cb0e946597bd0e049ed2f866e79e576e8e213d3d1c
3878+
"get-port@npm:^7.0.0":
3879+
version: 7.1.0
3880+
resolution: "get-port@npm:7.1.0"
3881+
checksum: 10c0/896051fea0fd3df58c050566754ab91f46406e898ce0c708414739d908a5ac03ffef3eca7a494ea9cc1914439e8caccd2218010d1eeabdde914b9ff920fa28fc
38613882
languageName: node
38623883
linkType: hard
38633884

0 commit comments

Comments
 (0)