@contexts/chrome is The Remote Chrome Context For Testing Like Webdriver.
yarn add -E @contexts/chromeThe package is available by importing its default function:
import ChromeContext from '@contexts/chrome'The class can be used either as a context, or as a persistent context in Zoroaster testing framework to eliminate the need to manually write set-up and tear-down routines in tests. The context will connect to a headless chrome and expose API for testing.
import { ok } from 'zoroaster/assert'
import ChromeContext from '@contexts/chrome'
/** @type {Object.<string, (c: ChromeContext)>} */
const T = {
persistentContext: ChromeContext,
async 'navigates to a web page'({ Page, evaluate, navigate }) {
await navigate('about:blank')
await Page.loadEventFired()
const { value } = await evaluate('window.navigator.userAgent', false)
ok(/HeadlessChrome/.test(value))
},
}
export default TNavigates to a webpage.
Evaluates an expression and returns the result. By default, the outcome will be serialised on the client and deserialised on the receiving end by the context using JSON to enable passing objects. To disable that, the json argument should be set to false.
The enabled page.
The enabled network.
![]() | © Art Deco for Depack 2019 | ![]() | Tech Nation Visa Sucks |
|---|

