Skip to content

Commit 1bded11

Browse files
authored
Merge pull request codediodeio#114 from JeremyVoisin/feature/emulator-tests
Permit the use of firebase emulator for testing
2 parents 648c0f9 + 1f147f5 commit 1bded11

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig } from '@playwright/test';
22

33
export default defineConfig({
44
webServer: {
5-
command: 'npm run build && npm run preview',
5+
command: 'firebase emulators:exec --only firestore,storage,auth "NODE_ENV=ci npm run build && npm run preview"',
66
port: 4173
77
},
88
testDir: 'tests',

src/routes/firebase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const db = getFirestore(app);
2121
export const auth = getAuth(app);
2222
export const storage = getStorage(app);
2323

24-
if (dev) {
24+
if (dev || import.meta.env.MODE === "ci") {
2525
connectAuthEmulator(auth, "http://localhost:9099");
2626
connectFirestoreEmulator(db, "localhost", 8080);
2727
connectStorageEmulator(storage, "localhost", 9199);

tests/auth.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ test.describe.serial("Auth", () => {
1616
});
1717

1818
test("User can sign in and out", async () => {
19-
await page.getByRole("button", { name: "Sign In" }).click();
19+
20+
await expect(page.getByRole("button", { name: "Sign In" })).toBeVisible();
21+
await page.getByRole("button", { name: "Sign In" }).click({delay: 1000});
2022
await expect(page.getByRole("button", { name: "Sign Out" })).toBeVisible();
21-
await expect(page.getByText("Signed In")).toBeVisible();
2223

2324
await page.getByRole("button", { name: "Sign Out" }).click();
2425
await expect(page.getByRole("button", { name: "Sign In" })).toBeVisible();

0 commit comments

Comments
 (0)