@augment-vir/test
Version:
A universal testing suite that works with Mocha style test runners _and_ Node.js's built-in test runner.
58 lines (57 loc) • 2.63 kB
TypeScript
import { RuntimeEnvError } from '@augment-vir/core';
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").clickElement;
/** Deletes all text that has been typed into the given `<input>` element. */
deleteInputText: typeof import("../test-web/type-into-element").deleteAllTextInInput;
/** Repeatedly tries to focus the given element until it is focused. */
ensureFocus: typeof import("../test-web/element-test-focus").focusElement;
/** Moves the mouse to the center of the given element. */
moveMouseTo: typeof import("../test-web/click-element").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").renderElement;
/** Focus the given element and then type the given string. */
typeIntoElement: typeof import("../test-web/type-into-element").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").typeString;
}>;
/**
* 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>;
export {};