* Visits the href with a document request. * * @param href The href you want to visit * @param waitForHydration Wait for the page to full load/hydrate? * - `undefined` to wait for the document `load` event * - `true` wait for the network to be idle, so everything should be loaded
(href: string, waitForHydration?: boolean)
| 29 | * to start loading (mostly useful for testing deferred responses) |
| 30 | */ |
| 31 | async goto(href: string, waitForHydration?: boolean): Promise<Response> { |
| 32 | let response = await this.page.goto(this.app.serverUrl + href, { |
| 33 | waitUntil: |
| 34 | waitForHydration === true |
| 35 | ? "networkidle" |
| 36 | : waitForHydration === false |
| 37 | ? "commit" |
| 38 | : "load", |
| 39 | }); |
| 40 | if (response == null) |
| 41 | throw new Error( |
| 42 | "Unexpected null response, possible about:blank request or same-URL redirect", |
| 43 | ); |
| 44 | |
| 45 | if (waitForHydration === false) { |
| 46 | await this.page.waitForFunction( |
| 47 | () => !!document.body && document.body.children.length > 0, |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | return response; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Finds a link on the page with a matching href, clicks it, and waits for |
no outgoing calls
no test coverage detected