@@ -3,27 +3,28 @@ import { useTestContext } from '../scripts/test-utils'
33
44import type { Page } from 'playwright-core'
55
6- export function sleep ( delay : number ) {
6+ export function sleep ( delay : number ) : Promise < void > {
77 return new Promise ( resolve => setTimeout ( resolve , delay ) )
88}
99
1010export async function getText (
1111 page : Page ,
1212 selector : string ,
1313 options ?: Parameters < Page [ 'locator' ] > [ 1 ]
14- ) {
14+ ) : Promise < string > {
1515 return ( await page . locator ( selector , options ) . allTextContents ( ) ) [ 0 ]
1616}
1717
1818export async function getData (
1919 page : Page ,
2020 selector : string ,
2121 options ?: Parameters < Page [ 'locator' ] > [ 1 ]
22- ) {
22+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23+ ) : Promise < any > {
2324 return JSON . parse ( await page . locator ( selector , options ) . innerText ( ) )
2425}
2526
26- export async function assetLocaleHead ( page : Page , headSelector : string ) {
27+ export async function assetLocaleHead ( page : Page , headSelector : string ) : Promise < void > {
2728 const localeHeadValue = await getData ( page , headSelector )
2829 const headHandle = await page . locator ( 'head' ) . elementHandle ( )
2930 await page . evaluateHandle (
@@ -47,15 +48,16 @@ export async function assetLocaleHead(page: Page, headSelector: string) {
4748 await headHandle ?. dispose ( )
4849}
4950
50- export function getDom ( html : string ) {
51+ export function getDom ( html : string ) : Document {
5152 return new JSDOM ( html ) . window . document
5253}
5354
54- export function getDataFromDom ( dom : Document , selector : string ) {
55+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56+ export function getDataFromDom ( dom : Document , selector : string ) : any {
5557 return JSON . parse ( dom . querySelector ( selector ) ! . textContent ! . replace ( '"' , '"' ) )
5658}
5759
58- export function assertLocaleHeadWithDom ( dom : Document , headSelector : string ) {
60+ export function assertLocaleHeadWithDom ( dom : Document , headSelector : string ) : void {
5961 const localeHead = getDataFromDom ( dom , headSelector )
6062 const headData = [ ...localeHead . link , ...localeHead . meta ]
6163 for ( const head of headData ) {
@@ -73,7 +75,7 @@ export function assertLocaleHeadWithDom(dom: Document, headSelector: string) {
7375 }
7476}
7577
76- export function url ( path : string ) {
78+ export function url ( path : string ) : string {
7779 // eslint-disable-next-line vue-composable/composable-placement -- NOTE(kazupon): not a composable
7880 const ctx = useTestContext ( )
7981
0 commit comments