UNPKG

@augment-vir/test

Version:

A universal testing suite that works with Mocha style test runners _and_ Node.js's built-in test runner.

60 lines (59 loc) 2.9 kB
import { RuntimeEnvError } from '@augment-vir/core'; export { type ElementCasesOptions, type ElementTestCase, type ElementTestCaseExpect, } from '../test-web/element-cases.js'; declare function importWebTestApi(this: void): Promise<RuntimeEnvError | { /** * Cleans up all rendered test HTML by removing the actual wrapper nodes. Common use case is * at the end of each test. */ cleanupRender: typeof import("@open-wc/testing-helpers").fixtureCleanup; /** Clicks the center of the given element. */ click: typeof import("../test-web/click-element.js").clickElement; /** Deletes all text that has been typed into the given `<input>` element. */ deleteInputText: typeof import("../test-web/type-into-element.js").deleteAllTextInInput; /** Repeatedly tries to focus the given element until it is focused. */ ensureFocus: typeof import("../test-web/element-test-focus.js").focusElement; /** Moves the mouse to the center of the given element. */ moveMouseTo: typeof import("../test-web/click-element.js").moveToElement; /** * Renders a string or TemplateResult and puts it in the DOM via a fixtureWrapper. * * Uses `fixture` from `@open-wc/testing-helpers`. * * @example * * ```ts * import {testWeb} from '@augment-vir/test'; * import {html} from 'element-vir'; * * const rendered = await testWeb.render(html` * <${MyElement}><span></span></${MyElement}> * `); * ``` * * @returns A Promise that will resolve to the first child of the rendered HTML. */ render: typeof import("@open-wc/testing-helpers").fixture; /** * Accepts an element-vir element definition, requires the elements inputs (if any), renders * the element and returns the instance. */ renderElement: typeof import("../test-web/render-element.js").renderElement; /** Focus the given element and then type the given string. */ typeIntoElement: typeof import("../test-web/type-into-element.js").typeStringIntoElement; /** * Types the given string as if it were input by a keyboard. This doesn't try to type into * any element in particular, it'll go wherever the current focus is, if any. */ typeText: typeof import("../test-web/type-into-element.js").typeString; /** Create multiple test cases for element testing. */ elementCases: typeof import("../test-web/element-cases.js").elementCases; }>; /** * A suite of web test helpers. This is only accessible within a browser runtime. If accessed * outside of a browser runtime, it'll be an Error instead of a collection of test helpers. * * @category Test * @category Package : @augment-vir/test * @package [`@augment-vir/test`](https://www.npmjs.com/package/@augment-vir/test) */ export declare const testWeb: Exclude<Awaited<ReturnType<typeof importWebTestApi>>, Error>;