mirror of
https://github.com/hanzoai/openid-client.git
synced 2026-09-24 17:01:10 +00:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
import { createServer } from 'node:http'
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
const script = readFileSync('./tap/run-browser.js', 'utf-8')
|
|
|
|
test('passes tests', async ({ page }) => {
|
|
const server = createServer((req, res) => {
|
|
if (req.url === '/run-browser.js') {
|
|
res.writeHead(200, { 'Content-Type': 'application/javascript' })
|
|
res.end(script)
|
|
} else {
|
|
res.writeHead(200, { 'Content-Type': 'text/html' })
|
|
res.end(
|
|
'<!DOCTYPE html><html><head></head><body><script type="module" src="/run-browser.js"></script></body></html>',
|
|
)
|
|
}
|
|
})
|
|
|
|
await new Promise<void>((resolve) => server.listen(0, resolve))
|
|
const port = (server.address() as import('node:net').AddressInfo).port
|
|
|
|
page.on('console', (msg) => {
|
|
if (msg.type() === 'log') {
|
|
console.log(msg.text())
|
|
}
|
|
})
|
|
|
|
await page.goto(`http://localhost:${port}`)
|
|
|
|
let stats
|
|
do {
|
|
await page.waitForTimeout(1000)
|
|
stats = await page.evaluate(() => (globalThis as any).stats)
|
|
} while (!stats)
|
|
|
|
server.close()
|
|
|
|
expect(stats.failed).toBe(0)
|
|
})
|