Skip to content

Commit 846f7b1

Browse files
committed
test: migrate integration tests and vscode extension tests
1 parent fd88b59 commit 846f7b1

6 files changed

Lines changed: 17 additions & 12 deletions

File tree

firebase-vscode/src/test/runTest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ async function main() {
1313
const extensionTestsPath = path.resolve(__dirname, "./suite/index");
1414

1515
// Download VS Code, unzip it and run the integration test
16+
const tmpUserData = path.join("/tmp", `vsc-ud-${Math.random().toString(36).substring(2, 7)}`);
1617
await runTests({
1718
extensionDevelopmentPath,
1819
extensionTestsPath,
20+
launchArgs: ["--user-data-dir", tmpUserData],
1921
});
2022
} catch (err) {
2123
console.error("Failed to run tests");

firebase-vscode/src/test/suite/execution-error-handling.test.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import * as gif from "../../../../src/gemini/fdcExperience";
66
import { dataConnectConfigs } from "../../data-connect/config";
77
import { ResultValue } from "../../result";
88
import { registerExecution } from "../../data-connect/execution/execution";
9+
import { requireAuthWrapper } from "../../cli";
910
import * as auth from "../../../../src/auth";
10-
import * as nock from "nock";
11+
import nock from "../../../../src/test/helpers/nock";
1112
import { setAccessToken } from "../../../../src/apiv2";
13+
import { googleOrigin } from "../../../../src/api";
1214
import { configstore } from "../../../../src/configstore";
1315

1416
firebaseSuite(
@@ -19,15 +21,21 @@ firebaseSuite(
1921
let authStub: any;
2022
let executionDisposable: vscode.Disposable;
2123

22-
setup(() => {
24+
setup(async () => {
25+
nock.cleanAll();
2326
showErrorMessageStub = stub(vscode.window, "showErrorMessage");
2427
showInformationMessageStub = stub(
2528
vscode.window,
2629
"showInformationMessage",
2730
);
28-
authStub = stub(auth, "getAccessToken").resolves({
29-
access_token: "an_access_token",
30-
});
31+
process.env.FIREBASE_TOKEN = "mock_refresh_token";
32+
nock(googleOrigin())
33+
.post("/oauth2/v3/token")
34+
.reply(200, {
35+
access_token: "an_access_token",
36+
expires_in: 3600,
37+
});
38+
await requireAuthWrapper(false);
3139
setAccessToken("an_access_token");
3240

3341
stub(vscode.window, "withProgress").callsFake(async (options, task) => {
@@ -72,11 +80,10 @@ firebaseSuite(
7280
analyticsLogger,
7381
emulatorsController,
7482
);
75-
76-
nock.cleanAll();
7783
});
7884

7985
teardown(() => {
86+
delete process.env.FIREBASE_TOKEN;
8087
executionDisposable.dispose();
8188
restore();
8289
nock.cleanAll();

scripts/hosting-tests/rewrites-tests/tests.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as tmp from "tmp";
66
import * as firebase from "../../../src";
77
import { execSync } from "child_process";
88
import { command as functionsDelete } from "../../../src/commands/functions-delete";
9-
import fetch, { Request } from "node-fetch";
109
import { FirebaseError } from "../../../src/error";
1110

1211
tmp.setGracefulCleanup();

scripts/hosting-tests/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ echo "${DATE}" > "public/${TARGET_FILE}"
5151
echo "Initialized temp directory."
5252

5353
echo "Testing local serve..."
54-
firebase serve --only hosting --project "${FBTOOLS_TARGET_PROJECT}" --port "${PORT}" &
54+
firebase serve --only hosting --project "${FBTOOLS_TARGET_PROJECT}" --port "${PORT}" --debug &
5555
PID="$!"
5656
sleep 5
5757
VALUE="$(curl localhost:${PORT}/${TARGET_FILE})"

scripts/integration-helpers/framework.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import fetch, { Response } from "node-fetch";
2-
31
import { CLIProcess } from "./cli";
42
import { Emulators } from "../../src/emulator/types";
53

scripts/storage-emulator-integration/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as fs from "fs";
22
import * as path from "path";
3-
import fetch from "node-fetch";
43
import * as crypto from "crypto";
54
import * as os from "os";
65
import { FrameworkOptions } from "../integration-helpers/framework";

0 commit comments

Comments
 (0)