-
Notifications
You must be signed in to change notification settings - Fork 3
/
page.ts
44 lines (42 loc) · 1.23 KB
/
page.ts
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { createInteractor } from '@interactors/core';
const PageInteractor = createInteractor<HTMLHtmlElement>('Page')
.selector(':root')
.filters({
title: (element) => element.ownerDocument.title,
url: (element) => {
let url = new URL(element.ownerDocument.location.href);
let search = new URLSearchParams(element.ownerDocument.location.search);
search.delete('bigtest-interactor-page-number');
url.search = search.toString();
return url.toString();
},
});
/**
* This {@link Interactor} can be used to assert on global properties of the
* page. When using the BigTest test runner, it can also be used for
* interacting with the page itself, for example through nagivation.
*
* ### Example
*
* ``` typescript
* await Page.has({ title: 'Welcome to my app!' });
* ```
*
* Navigation, for BigTest test runner only:
*
* ``` typescript
* await Page.visit('/archive');
* ```
*
* ### Filters
*
* - `title`: *string* – the title of the document
* - `url`: *string* – the URL of the document
*
* ### Actions
*
* - `visit(path: string)`: *{@link Interaction}* – visit the given path in the test frame, BigTest runner only.
*
* @category Interactor
*/
export const Page = PageInteractor();