From dc9252dd33fab9370ebdfd6c1d904a524c80d1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFs=20Poujade?= <lois.poujade@tetras-libre.fr> Date: Mon, 28 Nov 2022 16:35:37 +0100 Subject: [PATCH] Different local link --- __tests__/index.html | 5 +++++ __tests__/main.js | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 __tests__/index.html diff --git a/__tests__/index.html b/__tests__/index.html new file mode 100644 index 0000000..15175ea --- /dev/null +++ b/__tests__/index.html @@ -0,0 +1,5 @@ +<!doctype html> +<html> + <head><title>hello</title></head + <body><p>text <a href="https://example.org/">and a link</a></p></body> +</html> diff --git a/__tests__/main.js b/__tests__/main.js index 9bd29d4..20e63dd 100644 --- a/__tests__/main.js +++ b/__tests__/main.js @@ -15,20 +15,20 @@ describe('Open example', () => { describe('Open local HTTP server', () => { beforeAll(async () => { - let response = await page.goto('http://127.0.0.1:4488'); + let response = await page.goto('http://127.0.0.1:4488/__tests__/index.html'); expect(response.status()).toBe(200); }); it('has the correct page title', async () => { const title = await page.title(); - expect(title).toBe('Index of /'); + expect(title).toBe('hello'); }); it('has the correct link', async () => { - await page.waitForSelector('a[href="./jest.json"]'); - await expect(page).toMatchElement('a[href="./jest.json"]'); + await page.waitForSelector('a[href="https://example.org/"]'); + await expect(page).toMatchElement('a[href="https://example.org/"]'); }); }); -describe('Open example', () => { +describe('Open example bis', () => { beforeAll(async () => { let response = await page.goto('https://example.org'); expect(response.status()).toBe(200); @@ -43,17 +43,17 @@ describe('Open example', () => { }); }); -describe('Open local HTTP server', () => { +describe('Open local HTTP server bis', () => { beforeAll(async () => { - let response = await page.goto('http://127.0.0.1:4488'); + let response = await page.goto('http://127.0.0.1:4488/__tests__/index.html'); expect(response.status()).toBe(200); }); it('has the correct page title', async () => { const title = await page.title(); - expect(title).toBe('Index of /'); + expect(title).toBe('hello'); }); it('has the correct link', async () => { - await page.waitForSelector('a[href="./jest.json"]'); - await expect(page).toMatchElement('a[href="./jest.json"]'); + await page.waitForSelector('a[href="https://example.org/"]'); + await expect(page).toMatchElement('a[href="https://example.org/"]'); }); }); -- GitLab