forked from sheepzh/time-tracker-4-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.test.ts
More file actions
30 lines (24 loc) · 880 Bytes
/
base.test.ts
File metadata and controls
30 lines (24 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import axe, { source } from "axe-core"
import { type Page } from 'puppeteer'
import { launchBrowser, type LaunchContext } from "../common/base"
type AxeType = typeof axe
let context: LaunchContext
describe('After installed', () => {
beforeEach(async () => context = await launchBrowser())
// afterEach(async () => context.close())
test('Open the official page', async () => {
const page = await context.openAppPage("/data/dashboard")
await initAxe(page)
const result = await page.evaluate(async () => {
// axe.run()
const axeRes = await (window as unknown as { axe: AxeType }).axe.run()
console.log(axeRes)
return axeRes
})
}, 5000)
})
export const initAxe = async (page: Page) => {
await page.evaluate(async (source: string) => {
await eval(source)
}, source)
}