|
1 | 1 | import { expect, test } from '@playwright/test';
|
2 | 2 | import { waitForError } from '@sentry-internal/test-utils';
|
3 | 3 |
|
4 |
| -test('Index page', async ({ page }) => { |
5 |
| - const result = await page.goto('http://localhost:8787/'); |
6 |
| - expect(result?.status?.()).toBe(200); |
7 |
| - await expect(page.textContent('body > pre')).resolves.toBe('Hello World!'); |
| 4 | +test('Index page', async ({ baseURL }) => { |
| 5 | + const result = await fetch(baseURL!); |
| 6 | + expect(result.status).toBe(200); |
| 7 | + await expect(result.text()).resolves.toBe('Hello World!'); |
8 | 8 | })
|
9 | 9 |
|
10 |
| -test('worker\'s withSentry', async () => { |
| 10 | +test('worker\'s withSentry', async ({baseURL}) => { |
11 | 11 | const eventWaiter = waitForError('cloudflare-workers', (event) => {
|
12 | 12 | return event.exception?.values?.[0]?.mechanism?.type === 'cloudflare';
|
13 | 13 | });
|
14 |
| - const response = await fetch('http://localhost:8787/throwException'); |
| 14 | + const response = await fetch(`${baseURL}/throwException`); |
15 | 15 | expect(response.status).toBe(500);
|
16 | 16 | const event = await eventWaiter;
|
17 | 17 | expect(event.exception?.values?.[0]?.value).toBe('To be recorded in Sentry.');
|
18 | 18 | })
|
19 | 19 |
|
20 |
| -test('RPC method which throws an exception to be logged to sentry', async () => { |
| 20 | +test('RPC method which throws an exception to be logged to sentry', async ({baseURL}) => { |
21 | 21 | const eventWaiter = waitForError('cloudflare-workers', (event) => {
|
22 | 22 | return event.exception?.values?.[0]?.mechanism?.type === 'cloudflare_durableobject';
|
23 | 23 | });
|
24 |
| - const response = await fetch('http://localhost:8787/rpc/throwException'); |
| 24 | + const response = await fetch(`${baseURL}/rpc/throwException`); |
25 | 25 | expect(response.status).toBe(500);
|
26 | 26 | const event = await eventWaiter;
|
27 | 27 | expect(event.exception?.values?.[0]?.value).toBe('Should be recorded in Sentry.');
|
28 | 28 | });
|
29 |
| -test('Request processed by DurableObject\'s fetch is recorded', async () => { |
| 29 | +test('Request processed by DurableObject\'s fetch is recorded', async ({baseURL}) => { |
30 | 30 | const eventWaiter = waitForError('cloudflare-workers', (event) => {
|
31 | 31 | return event.exception?.values?.[0]?.mechanism?.type === 'cloudflare_durableobject';
|
32 | 32 | });
|
33 |
| - const response = await fetch('http://localhost:8787/pass-to-object/throwException'); |
| 33 | + const response = await fetch(`${baseURL}/pass-to-object/throwException`); |
34 | 34 | expect(response.status).toBe(500);
|
35 | 35 | const event = await eventWaiter;
|
36 | 36 | expect(event.exception?.values?.[0]?.value).toBe('Should be recorded in Sentry.');
|
|
0 commit comments