|
1 | | -/* eslint-disable import/no-unresolved */ |
2 | 1 | import { check } from 'k6'; |
3 | | -import { browser } from 'k6/browser'; |
4 | | -/* eslint-enable import/no-unresolved */ |
| 2 | +import http from 'k6/http'; |
5 | 3 | import { defaultOptions, url } from './_util.js'; |
6 | 4 |
|
7 | | -export const options = defaultOptions(true); |
| 5 | +export const options = defaultOptions(false); |
8 | 6 |
|
9 | | -export default async () => { |
10 | | - const streamingUrl = url('stream_async_components?delay=0'); |
11 | | - const page = await browser.newPage(); |
12 | | - try { |
13 | | - await page.goto(streamingUrl); |
14 | | - await page.waitForFunction( |
15 | | - () => !document.body.textContent.includes('Loading'), |
16 | | - { |
17 | | - // in milliseconds |
18 | | - timeout: 5000, |
19 | | - }, |
20 | | - ); |
21 | | - check(await page.locator('html').textContent(), { |
22 | | - 'has all comments': (text) => { |
23 | | - const commentIds = [1, 2, 3, 4]; |
24 | | - return commentIds.every((id) => text.includes(`Comment ${id}`)); |
25 | | - }, |
26 | | - }); |
27 | | - } finally { |
28 | | - await page.close(); |
29 | | - } |
| 7 | +export default () => { |
| 8 | + const streamingUrl = url('stream_async_components?delay=5'); |
| 9 | + check(http.get(streamingUrl), { |
| 10 | + 'status was 200': (res) => res.status === 200, |
| 11 | + 'has all comments': (res) => { |
| 12 | + const body = res.html().text(); |
| 13 | + const commentIds = [1, 2, 3, 4]; |
| 14 | + const hasAllComments = commentIds.every((commentId) => body.includes(`Comment ${commentId}`)); |
| 15 | + const hasFailedRequests = !!body.match(/Request to .+ failed/i); |
| 16 | + return hasAllComments && !hasFailedRequests; |
| 17 | + }, |
| 18 | + }); |
30 | 19 | }; |
0 commit comments