Skip to content
Snippets Groups Projects
Verified Commit 6e273469 authored by Loïs Poujade's avatar Loïs Poujade
Browse files

Add wait/HTTP status check

parent 836c8628
No related branches found
No related tags found
No related merge requests found
describe('Open example', () => { describe('Open example', () => {
beforeAll(async () => { beforeAll(async () => {
await page.goto('https://example.org'); await page.goto('https://example.org');
expect(page.status()).toBe(200);
}); });
it('has the correct page title', async () => { it('has the correct page title', async () => {
const title = await page.title(); const title = await page.title();
expect(title).toBe('Example Domain'); expect(title).toBe('Example Domain');
}); });
it('has the main text', async () => { 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"]'); await expect(page).toMatchElement('a[href="https://www.iana.org/domains/example"]');
}); });
}); });
...@@ -14,12 +16,14 @@ describe('Open example', () => { ...@@ -14,12 +16,14 @@ describe('Open example', () => {
describe('Open local HTTP server', () => { describe('Open local HTTP server', () => {
beforeAll(async () => { beforeAll(async () => {
await page.goto('http://127.0.0.1:4488'); await page.goto('http://127.0.0.1:4488');
expect(page.status()).toBe(200);
}); });
it('has the correct page title', async () => { it('has the correct page title', async () => {
const title = await page.title(); const title = await page.title();
expect(title).toBe('Index of /'); expect(title).toBe('Index of /');
}); });
it('has the correct link', async () => { it('has the correct link', async () => {
await page.waitForSelector('a[href="./jest.json"]');
await expect(page).toMatchElement('a[href="./jest.json"]'); await expect(page).toMatchElement('a[href="./jest.json"]');
}); });
}); });
...@@ -27,12 +31,14 @@ describe('Open local HTTP server', () => { ...@@ -27,12 +31,14 @@ describe('Open local HTTP server', () => {
describe('Open example', () => { describe('Open example', () => {
beforeAll(async () => { beforeAll(async () => {
await page.goto('https://example.org'); await page.goto('https://example.org');
expect(page.status()).toBe(200);
}); });
it('has the correct page title', async () => { it('has the correct page title', async () => {
const title = await page.title(); const title = await page.title();
expect(title).toBe('Example Domain'); expect(title).toBe('Example Domain');
}); });
it('has the main text', async () => { 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"]'); await expect(page).toMatchElement('a[href="https://www.iana.org/domains/example"]');
}); });
}); });
...@@ -40,12 +46,14 @@ describe('Open example', () => { ...@@ -40,12 +46,14 @@ describe('Open example', () => {
describe('Open local HTTP server', () => { describe('Open local HTTP server', () => {
beforeAll(async () => { beforeAll(async () => {
await page.goto('http://127.0.0.1:4488'); await page.goto('http://127.0.0.1:4488');
expect(page.status()).toBe(200);
}); });
it('has the correct page title', async () => { it('has the correct page title', async () => {
const title = await page.title(); const title = await page.title();
expect(title).toBe('Index of /'); expect(title).toBe('Index of /');
}); });
it('has the correct link', async () => { it('has the correct link', async () => {
await page.waitForSelector('a[href="./jest.json"]');
await expect(page).toMatchElement('a[href="./jest.json"]'); await expect(page).toMatchElement('a[href="./jest.json"]');
}); });
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment