Skip to content

Commit d401ba3

Browse files
committed
WIP debug log page contents
1 parent a380f59 commit d401ba3

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

examples/publish-ci/cra5/playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default defineConfig({
66
timeout: 120 * 1000,
77
reuseExistingServer: !process.env.CI,
88
},
9+
timeout: 120 * 1000,
910
use: {
1011
headless: true,
1112
viewport: { width: 1280, height: 720 },
Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,63 @@
11
import { test, expect } from '@playwright/test'
2+
import { format } from 'prettier'
3+
4+
function delay(ms: number) {
5+
return new Promise((resolve) => setTimeout(resolve, ms))
6+
}
27

38
test('RTK / RTKQ Interactions', async ({ page }) => {
49
await page.goto('http://localhost:3000')
510

611
const counterValue = page.getByTestId('counter-value')
7-
expect(counterValue).toHaveText('0', { timeout: 0 })
12+
const counterText = await counterValue.innerText({ timeout: 0 })
13+
expect(counterText).toBe('0')
814

915
const increment = page.getByRole('button', { name: 'Increment value' })
1016
await increment.click()
1117

12-
expect(counterValue).toHaveText('1')
18+
const counterText2 = await counterValue.innerText({ timeout: 0 })
19+
expect(counterText2).toBe('1')
1320

14-
const timeValue = page.getByTestId('time-value')
15-
await timeValue.getByText(/\d+:\d+:\d+ (A|P)M/).waitFor({ timeout: 10000 })
21+
console.log('CounterText2: ', counterText2)
22+
23+
// expect(counterValue).toHaveText('1')
1624

25+
async function logHTML(message = '') {
26+
const html = await page.innerHTML('div#root')
27+
const formattedHTML = format(html, { parser: 'html' })
28+
console.log(message, formattedHTML)
29+
}
30+
31+
logHTML('Page: ')
32+
33+
const timeValue = page.getByTestId('time-value')
1734
const postValue = page.getByTestId('post-value')
18-
await postValue.getByText('A sample post').waitFor({ timeout: 10000 })
1935

20-
// expect(timeValue).toHaveText(, {timeout: 5000, });
36+
await expect(timeValue).toHaveText(/\d+:\d+:\d+ (A|P)M/, { timeout: 10000 })
37+
await expect(postValue).toHaveText('A sample post', { timeout: 10000 })
38+
39+
// console.log('timeValue before: ', await timeValue.innerText())
40+
// console.log('postValue before: ', await postValue.innerText())
41+
// await delay(5000)
42+
43+
// console.log('timeValue after: ', await timeValue.innerText())
44+
// console.log('postValue after: ', await postValue.innerText())
45+
//
46+
// await page.getByText(/\d+:\d+:\d+ (A|P)M/).waitFor({ timeout: 10000 })
47+
48+
//
49+
//
50+
// await page.getByText('A sample post').waitFor({ timeout: 10000 })
51+
52+
// try {
53+
// } catch (err) {
54+
// } finally {
55+
// logHTML('After timevalue')
56+
// }
57+
58+
// try {
59+
// } catch (err) {
60+
// } finally {
61+
// logHTML('After postvalue')
62+
// }
2163
})

0 commit comments

Comments
 (0)