Skip to content

Commit 6f6d045

Browse files
Copilotgarrytrinder
andcommitted
Fix shell test by removing fs.existsSync stubbing
Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com>
1 parent e31c1ba commit 6f6d045

1 file changed

Lines changed: 7 additions & 21 deletions

File tree

src/test/shell.test.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* Tests for pure utility functions in shell.ts.
44
*/
55
import * as assert from 'assert';
6-
import * as sinon from 'sinon';
7-
import * as fs from 'fs';
86
import { getPackageIdentifier, resolveDevProxyExecutable } from '../utils/shell';
97
import {
108
PackageManager,
@@ -44,15 +42,7 @@ suite('getPackageIdentifier', () => {
4442
});
4543

4644
suite('resolveDevProxyExecutable', () => {
47-
let existsSyncStub: sinon.SinonStub;
48-
49-
setup(() => {
50-
existsSyncStub = sinon.stub(fs, 'existsSync');
51-
});
52-
53-
teardown(() => {
54-
sinon.restore();
55-
});
45+
const NONEXISTENT_DEVPROXY_COMMAND = 'devproxy-command-that-does-not-exist-for-tests';
5646

5747
test('should return custom path when provided and non-empty', async () => {
5848
const customPath = '/custom/path/to/devproxy';
@@ -67,22 +57,18 @@ suite('resolveDevProxyExecutable', () => {
6757
});
6858

6959
test('should ignore empty custom path and proceed with auto-detection', async () => {
70-
// With empty custom path and no auto-detection success, should return bare command
71-
existsSyncStub.returns(false);
72-
const result = await resolveDevProxyExecutable('devproxy', '');
60+
const result = await resolveDevProxyExecutable(NONEXISTENT_DEVPROXY_COMMAND, '');
7361
// Will fall through to bare command since nothing else succeeds
74-
assert.strictEqual(result, 'devproxy');
62+
assert.strictEqual(result, NONEXISTENT_DEVPROXY_COMMAND);
7563
});
7664

7765
test('should ignore whitespace-only custom path', async () => {
78-
existsSyncStub.returns(false);
79-
const result = await resolveDevProxyExecutable('devproxy', ' ');
80-
assert.strictEqual(result, 'devproxy');
66+
const result = await resolveDevProxyExecutable(NONEXISTENT_DEVPROXY_COMMAND, ' ');
67+
assert.strictEqual(result, NONEXISTENT_DEVPROXY_COMMAND);
8168
});
8269

8370
test('should handle undefined custom path', async () => {
84-
existsSyncStub.returns(false);
85-
const result = await resolveDevProxyExecutable('devproxy', undefined);
86-
assert.strictEqual(result, 'devproxy');
71+
const result = await resolveDevProxyExecutable(NONEXISTENT_DEVPROXY_COMMAND, undefined);
72+
assert.strictEqual(result, NONEXISTENT_DEVPROXY_COMMAND);
8773
});
8874
});

0 commit comments

Comments
 (0)