Skip to content

Commit d3ae00c

Browse files
committed
Add execa mock to fix timeout on Node.js 20
The UI prompt tests were timing out on Node.js 20 because they were missing a mock for the execa call to get the registry URL. This caused the tests to hang when trying to execute `npm config get registry`. Added execa mock to both version.js and tags.js tests to return a fake registry URL, which prevents the actual command execution and makes the tests run much faster (600-900ms instead of 4-8s).
1 parent cb55fe4 commit d3ae00c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

test/ui/prompts/tags.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const testUi = test.macro(async (t, {version, tags, answers}, assertions) => {
2323
'./package-manager/index.js': {
2424
findLockfile: sinon.stub().resolves(undefined),
2525
},
26+
execa: {
27+
execa: sinon.stub().resolves({stdout: 'https://registry.npmjs.org/'}),
28+
},
2629
},
2730
});
2831

@@ -150,6 +153,9 @@ for (const {version} of fixtures) {
150153
'./package-manager/index.js': {
151154
findLockfile: sinon.stub().resolves(undefined),
152155
},
156+
execa: {
157+
execa: sinon.stub().resolves({stdout: 'https://registry.npmjs.org/'}),
158+
},
153159
},
154160
});
155161

test/ui/prompts/version.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const testUi = test.macro(async (t, {version, answers}, assertions) => {
1818
latestTagOrFirstCommit: sinon.stub().resolves('v1.0.0'),
1919
commitLogFromRevision: sinon.stub().resolves(''),
2020
},
21+
execa: {
22+
execa: sinon.stub().resolves({stdout: 'https://registry.npmjs.org/'}),
23+
},
2124
},
2225
});
2326

0 commit comments

Comments
 (0)