Skip to content

Commit

Permalink
[playwright] chore: Wait for api
Browse files Browse the repository at this point in the history
  • Loading branch information
helloitsdave committed Mar 16, 2024
1 parent 6d6ca05 commit 657c337
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions playwright/tests/note.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect, Page } from '@playwright/test';
import { test, expect, Page, Response } from '@playwright/test';

const TIMESTAMP = Date.now();
const NOTE_TITLE = `My note ${TIMESTAMP}`;
Expand All @@ -7,25 +7,24 @@ const EDITED_NOTE_TITLE = `Edited note ${TIMESTAMP}`;
const EDITED_NOTE_CONTENT = `Edited note content ${TIMESTAMP}`;

let page: Page;
let notesApi: Promise<Response>;

const timeout = 80 * 1000;

test.beforeAll(async ({ browser }, { timeout }) => {
page = await browser.newPage();

/** Free tier on render.com may take 60 seconds to startup */

const notesApi = page.waitForResponse((response) => response.url().includes("/api/notes") && response.status() === 200, { timeout });

await page.goto('/', { timeout });;

await notesApi;

await page.goto('/', { timeout });
});

test('Notes App e2e', async () => {

await test.step('Should have loaded', async () => {
await notesApi;

expect(page).toHaveTitle(/Notes/);
expect(page.getByTestId('spinner-container')).not.toBeVisible({ timeout });
});
Expand Down

0 comments on commit 657c337

Please sign in to comment.