UNPKG

playwright-testing-library

Version:
30 lines (29 loc) 1.12 kB
import type { Config, Selector, SynchronousQuery } from '../types'; declare const queryToSelector: (query: SynchronousQuery) => Selector; declare const buildTestingLibraryScript: ({ config }: { config: Config; }) => Promise<string>; /** * Alternative version of `Array.prototype.includes` that allows testing for * the existence of an item with a type that is a _superset_ of the type of the * items in the array. * * This allows us to use it to check whether an item of type `string` exists in * an array of string literals (e.g: `['foo', 'bar'] as const`) without TypeScript * complaining. It will, however, throw a compiler error if you try to pass an item * of type `number`. * * @example * const things = ['foo', 'bar'] as const; * * // error * const hasThing = (t: string) => things.includes(t); * * // compiles * const hasThing = (t: string) => includes(things, t); * * @param array array to search * @param item item to search for */ declare const includes: <T extends U, U>(array: readonly T[], item: U) => item is T; export { buildTestingLibraryScript, includes, queryToSelector };