diff --git a/__tests__/main.js b/__tests__/main.js index c5d2cd994e6384d3738436a1cce0d1125281d799..ca4809da7ea95892aca7ebdab5166d3906fa4f0b 100644 --- a/__tests__/main.js +++ b/__tests__/main.js @@ -1,12 +1,14 @@ describe('Open example', () => { beforeAll(async () => { await page.goto('https://example.org'); + expect(page.status()).toBe(200); }); it('has the correct page title', async () => { const title = await page.title(); expect(title).toBe('Example Domain'); }); it('has the main text', async () => { + await page.waitForSelector('a[href="https://www.iana.org/domains/example"]'); await expect(page).toMatchElement('a[href="https://www.iana.org/domains/example"]'); }); }); @@ -14,12 +16,14 @@ describe('Open example', () => { describe('Open local HTTP server', () => { beforeAll(async () => { await page.goto('http://127.0.0.1:4488'); + expect(page.status()).toBe(200); }); it('has the correct page title', async () => { const title = await page.title(); expect(title).toBe('Index of /'); }); it('has the correct link', async () => { + await page.waitForSelector('a[href="./jest.json"]'); await expect(page).toMatchElement('a[href="./jest.json"]'); }); }); @@ -27,12 +31,14 @@ describe('Open local HTTP server', () => { describe('Open example', () => { beforeAll(async () => { await page.goto('https://example.org'); + expect(page.status()).toBe(200); }); it('has the correct page title', async () => { const title = await page.title(); expect(title).toBe('Example Domain'); }); it('has the main text', async () => { + await page.waitForSelector('a[href="https://www.iana.org/domains/example"]'); await expect(page).toMatchElement('a[href="https://www.iana.org/domains/example"]'); }); }); @@ -40,12 +46,14 @@ describe('Open example', () => { describe('Open local HTTP server', () => { beforeAll(async () => { await page.goto('http://127.0.0.1:4488'); + expect(page.status()).toBe(200); }); it('has the correct page title', async () => { const title = await page.title(); expect(title).toBe('Index of /'); }); it('has the correct link', async () => { + await page.waitForSelector('a[href="./jest.json"]'); await expect(page).toMatchElement('a[href="./jest.json"]'); }); });