Skip to content

Commit fb32f38

Browse files
lexie011EzioLi01
andauthored
Add unit test for browser finder and child_process execution (#2300)
* Add unit test for browser finder and child_process execution * test for windows only --------- Co-authored-by: Ezio Li <[email protected]>
1 parent e215260 commit fb32f38

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/extension/appLauncher.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import * as assert from "assert";
55
import * as vscode from "vscode";
66
import * as path from "path";
77
import * as fs from "fs";
8+
import * as BrowserHelper from "vscode-js-debug-browsers";
9+
import * as sinon from "sinon";
10+
import * as child_process from "child_process";
11+
import * as os from "os";
812
import { AppLauncher } from "../../src/extension/appLauncher";
913
import { ProjectsStorage } from "../../src/extension/projectsStorage";
1014
import { activate, deactivate } from "../../src/extension/rn-extension";
@@ -174,4 +178,28 @@ suite("appLauncher", function () {
174178
assert.notStrictEqual(nodeModulesRoot1, nodeModulesRoot2);
175179
});
176180
});
181+
suite("launchBrowser", function () {
182+
test("expo web launch on edge browser", async function () {
183+
// test for windows only
184+
if (os.platform() === "win32") {
185+
try {
186+
const browserPath = {
187+
path: "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",
188+
};
189+
const browserFinderStub = sinon.stub(
190+
BrowserHelper.EdgeBrowserFinder.prototype,
191+
"findAll",
192+
);
193+
browserFinderStub.returns(Promise.resolve([browserPath]));
194+
child_process.spawn(browserPath.path, {
195+
detached: true,
196+
stdio: ["ignore"],
197+
});
198+
browserFinderStub.restore();
199+
} catch (err) {
200+
assert.fail(err);
201+
}
202+
}
203+
});
204+
});
177205
});

0 commit comments

Comments
 (0)