Skip to content

Commit

Permalink
waitForFunction 使ってみる
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Mar 1, 2024
1 parent ca33023 commit e8abade
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/messaging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ test('messaging pages', async ({ browser }) => {
await page1.click('#send-message')

// page2でメッセージが受信されたことを確認
await page2.waitForSelector('#received-messages li', { state: 'attached' })
const receivedMessage1 = await page2.$eval('#received-messages li', (el) => el.textContent)
await page2.waitForFunction(() => document.querySelectorAll('#received-messages li').length > 0)

// // 受信したメッセージが期待したものであるか検証
// console.log(`Received message on page2: ${receivedMessage1}`)
// test.expect(receivedMessage1).toBe('Hello from page1')

// page2からpage1へメッセージを送信
await page2.fill('input[name="message"]', 'Hello from page2')
await page2.click('#send-message')
// // page2からpage1へメッセージを送信
// await page2.fill('input[name="message"]', 'Hello from page2')
// await page2.click('#send-message')

// page1でメッセージが受信されたことを確認
await page1.waitForSelector('li', { state: 'attached' })
const receivedMessage2 = await page1.$eval('#received-messages li', (el) => el.textContent)
// // page1でメッセージが受信されたことを確認
await page1.waitForFunction(() => document.querySelectorAll('#received-messages li').length > 0)
// await page1.waitForSelector('li', { state: 'attached' })
// const receivedMessage2 = await page1.$eval('#received-messages li', (el) => el.textContent)

// // 受信したメッセージが期待したものであるか検証
// console.log(`Received message on page1: ${receivedMessage2}`)
Expand Down

0 comments on commit e8abade

Please sign in to comment.