@web/test-runner-commands
Advanced tools
Comparing version 0.4.2 to 0.4.3
import { Media } from '../dist/index'; | ||
import { Viewport } from '../dist/index'; | ||
import { SendKeysPayload } from '../dist/index'; | ||
import { A11ySnapshotPayload } from '../dist/index'; | ||
@@ -48,3 +49,3 @@ /** | ||
* | ||
* * @example | ||
* @example | ||
* ```ts | ||
@@ -56,3 +57,3 @@ * await sendKeys({ | ||
* | ||
* * @example | ||
* @example | ||
* ```ts | ||
@@ -67,2 +68,56 @@ * await sendKeys({ | ||
/** | ||
* Request a snapshot of the Accessibility Tree of the entire page or starting from | ||
* the element that is obtained via the `selector` property of the `payload` argument. | ||
* | ||
* Learn more about the tree that is returned from Playwright here: | ||
* - https://playwright.dev/docs/api/class-accessibility/ | ||
* | ||
* Learn more about the tree that is returned from Puppeteer here: | ||
* - https://pptr.dev/#?product=Puppeteer&show=api-class-accessibility | ||
* | ||
* @param payload An object including a `selector` property pointing to the root of the | ||
* a11y tree you'd like returned. | ||
* | ||
* @example | ||
* ```ts | ||
* await a11ySnapshot(); | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* await a11ySnapshot({ | ||
* selector: 'main' | ||
* }); | ||
* ``` | ||
*/ | ||
export function a11ySnapshot(payload: A11ySnapshotPayload): Promise<void>; | ||
/** | ||
* Walk the provided accessibility tree that starts on `node` and test each | ||
* node in the tree until one is found that meast the `test` provided. | ||
* | ||
* Learn more about the tree that is returned from Playwright here: | ||
* - https://playwright.dev/docs/api/class-accessibility/ | ||
* | ||
* Learn more about the tree that is returned from Puppeteer here: | ||
* - https://pptr.dev/#?product=Puppeteer&show=api-class-accessibility | ||
* | ||
* @param node | ||
* @param test | ||
* | ||
* @example | ||
* // return whether a node in the `snapshot` has `name: 'Label Text Value Text'` | ||
* ```ts | ||
* findAccessibilityNode<{ name: string }>( | ||
* snapshot, | ||
* (node) => node.name === 'Label Text Value Text' | ||
* ) | ||
* ``` | ||
*/ | ||
export function findAccessibilityNode<TNode>( | ||
node: TNode & { children: TNode[] }, | ||
test: (node: TNode) => boolean, | ||
): TNode | null; | ||
export { Media, Viewport, SendKeysPayload }; |
# @web/test-runner-commands | ||
## 0.4.3 | ||
### Patch Changes | ||
- 1d9411a3: Export `sendKeysPlugin` from `@web/test-runner-commands/plugins`. | ||
Loosen the typing of the command payload. | ||
- d2389bac: Add a11ySnapshotPlugin to acquire the current accessibility tree from the browser: | ||
```js | ||
import { a11ySnapshot, findAccessibilityNode } from '@web/test-runner-commands'; | ||
// ... | ||
const nodeName = 'Label Text'; | ||
const snapshot = await a11ySnapshot(); | ||
const foundNode = findAccessibilityNode(snapshot, node => node.name === nodeName); | ||
expect(foundNode).to.not.be.null; | ||
``` | ||
## 0.4.2 | ||
@@ -4,0 +23,0 @@ |
@@ -5,2 +5,3 @@ export { Viewport, setViewportPlugin } from './setViewportPlugin'; | ||
export { sendKeysPlugin, SendKeysPayload } from './sendKeysPlugin'; | ||
export { a11ySnapshotPlugin, A11ySnapshotPayload } from './a11ySnapshotPlugin'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sendKeysPlugin = exports.setUserAgentPlugin = exports.emulateMediaPlugin = exports.setViewportPlugin = void 0; | ||
exports.a11ySnapshotPlugin = exports.sendKeysPlugin = exports.setUserAgentPlugin = exports.emulateMediaPlugin = exports.setViewportPlugin = void 0; | ||
var setViewportPlugin_1 = require("./setViewportPlugin"); | ||
@@ -12,2 +12,4 @@ Object.defineProperty(exports, "setViewportPlugin", { enumerable: true, get: function () { return setViewportPlugin_1.setViewportPlugin; } }); | ||
Object.defineProperty(exports, "sendKeysPlugin", { enumerable: true, get: function () { return sendKeysPlugin_1.sendKeysPlugin; } }); | ||
var a11ySnapshotPlugin_1 = require("./a11ySnapshotPlugin"); | ||
Object.defineProperty(exports, "a11ySnapshotPlugin", { enumerable: true, get: function () { return a11ySnapshotPlugin_1.a11ySnapshotPlugin; } }); | ||
//# sourceMappingURL=index.js.map |
import { TestRunnerPlugin } from '@web/test-runner-core'; | ||
export declare type SendKeysPayload = { | ||
type: string; | ||
press: undefined; | ||
press?: undefined; | ||
} | { | ||
type: undefined; | ||
type?: undefined; | ||
press: string; | ||
@@ -8,0 +8,0 @@ }; |
{ | ||
"name": "@web/test-runner-commands", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
@@ -5,1 +5,2 @@ export { Viewport, setViewportPlugin } from './setViewportPlugin'; | ||
export { sendKeysPlugin, SendKeysPayload } from './sendKeysPlugin'; | ||
export { a11ySnapshotPlugin, A11ySnapshotPayload } from './a11ySnapshotPlugin'; |
@@ -6,4 +6,4 @@ import { TestRunnerPlugin } from '@web/test-runner-core'; | ||
export type SendKeysPayload = | ||
| { type: string; press: undefined } | ||
| { type: undefined; press: string }; | ||
| { type: string; press?: undefined } | ||
| { type?: undefined; press: string }; | ||
@@ -10,0 +10,0 @@ function isObject(payload: unknown): payload is Record<string, unknown> { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
45444
39
706