diff --git a/.all-contributorsrc b/.all-contributorsrc index 74e8584..2c48e92 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -50,6 +50,17 @@ "ideas", "test" ] + }, + { + "login": "airato", + "name": "Airat Aminev", + "avatar_url": "https://avatars3.githubusercontent.com/u/4506749?v=4", + "profile": "https://github.com/airato", + "contributions": [ + "code", + "test", + "tool" + ] } ], "repoType": "github" diff --git a/README.md b/README.md index dfd5dcd..38e171a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ [![downloads][downloads-badge]][npmtrends] [![MIT License][license-badge]][license] -[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors) [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] @@ -100,8 +100,8 @@ Thanks goes to these people ([emoji key][emojis]): -| [
Kent C. Dodds](https://kentcdodds.com)
[💻](https://github.com/kentcdodds/cypress-testing-library/commits?author=kentcdodds "Code") [📖](https://github.com/kentcdodds/cypress-testing-library/commits?author=kentcdodds "Documentation") [🚇](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/kentcdodds/cypress-testing-library/commits?author=kentcdodds "Tests") | [
Ivan Babak](https://sompylasar.github.io)
[💻](https://github.com/kentcdodds/cypress-testing-library/commits?author=sompylasar "Code") [🤔](#ideas-sompylasar "Ideas, Planning, & Feedback") | [
Łukasz Gandecki](http://team.thebrain.pro)
[💻](https://github.com/kentcdodds/cypress-testing-library/commits?author=lgandecki "Code") [⚠️](https://github.com/kentcdodds/cypress-testing-library/commits?author=lgandecki "Tests") | [
Peter Kamps](https://github.com/npeterkamps)
[💻](https://github.com/kentcdodds/cypress-testing-library/commits?author=npeterkamps "Code") [📖](https://github.com/kentcdodds/cypress-testing-library/commits?author=npeterkamps "Documentation") [🤔](#ideas-npeterkamps "Ideas, Planning, & Feedback") [⚠️](https://github.com/kentcdodds/cypress-testing-library/commits?author=npeterkamps "Tests") | -| :---: | :---: | :---: | :---: | +| [
Kent C. Dodds](https://kentcdodds.com)
[💻](https://github.com/kentcdodds/cypress-testing-library/commits?author=kentcdodds "Code") [📖](https://github.com/kentcdodds/cypress-testing-library/commits?author=kentcdodds "Documentation") [🚇](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/kentcdodds/cypress-testing-library/commits?author=kentcdodds "Tests") | [
Ivan Babak](https://sompylasar.github.io)
[💻](https://github.com/kentcdodds/cypress-testing-library/commits?author=sompylasar "Code") [🤔](#ideas-sompylasar "Ideas, Planning, & Feedback") | [
Łukasz Gandecki](http://team.thebrain.pro)
[💻](https://github.com/kentcdodds/cypress-testing-library/commits?author=lgandecki "Code") [⚠️](https://github.com/kentcdodds/cypress-testing-library/commits?author=lgandecki "Tests") | [
Peter Kamps](https://github.com/npeterkamps)
[💻](https://github.com/kentcdodds/cypress-testing-library/commits?author=npeterkamps "Code") [📖](https://github.com/kentcdodds/cypress-testing-library/commits?author=npeterkamps "Documentation") [🤔](#ideas-npeterkamps "Ideas, Planning, & Feedback") [⚠️](https://github.com/kentcdodds/cypress-testing-library/commits?author=npeterkamps "Tests") | [
Airat Aminev](https://github.com/airato)
[💻](https://github.com/kentcdodds/cypress-testing-library/commits?author=airato "Code") [⚠️](https://github.com/kentcdodds/cypress-testing-library/commits?author=airato "Tests") [🔧](#tool-airato "Tools") | +| :---: | :---: | :---: | :---: | :---: | diff --git a/package.json b/package.json index a5162df..a8af452 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "add-contributor": "kcd-scripts contributors add", "build": "kcd-scripts build", "lint": "kcd-scripts lint", - "test": "npm-run-all --parallel test:unit test:cypress", + "test": "npm-run-all --parallel test:unit test:cypress test:typings", "test:unit": "kcd-scripts test --no-watch", "test:unit:watch": "kcd-scripts test", "test:cypress:serve": "serve --listen 13370 ./cypress/fixtures/test-app", @@ -19,6 +19,8 @@ "test:cypress:open": "cypress open", "test:cypress": "npm-run-all --silent --parallel --race test:cypress:serve test:cypress:run", "test:cypress:dev": "npm-run-all --silent --parallel --race test:cypress:serve test:cypress:open", + "test:typings": "tsc -p tests/typescript-types/ --noemit", + "test:typings:watch": "tsc -p tests/typescript-types/ --noemit --watch", "validate": "kcd-scripts validate build,lint,test", "setup": "npm install && npm run validate -s", "precommit": "kcd-scripts precommit", @@ -50,6 +52,7 @@ "kcd-scripts": "^0.37.0", "npm-run-all": "^4.1.2", "serve": "^10.0.0", + "typescript": "^3.1.6", "wait-port": "^0.2.2" }, "peerDependencies": { diff --git a/tests/typescript-types/test.spec.ts b/tests/typescript-types/test.spec.ts new file mode 100644 index 0000000..8ce8c10 --- /dev/null +++ b/tests/typescript-types/test.spec.ts @@ -0,0 +1,45 @@ +describe('Foo', () => { + it('has proper types', () => { + cy.visit('#/foo') + + cy.getAllByPlaceholderText('foo').should(elements => { + // argument should be an array of HTML elements + expect(elements.length).to.eq(0) + expect(elements[0].tagName).to.eq(0) + }) + + // with regex + cy.queryByPlaceholderText<'a'>(/foo/).should(element => { + // node can be null + if (element) { + // argument should be an anchor + expect(element.href).to.eq('') + } + }) + + // with matcher function + const matcherFn = (content: string, element: HTMLElement) => true + + cy.queryByPlaceholderText(matcherFn).should(element => { + // node can be null + if (element) { + // argument should be an Audio element + expect(element.play).to.exist + } + }) + + // with matcher options + cy.queryAllByPlaceholderText('foo', { + collapseWhitespace: true, + exact: true, + trim: true, + }).should(elements => { + const el = elements[0] + // node can be null + if (el) { + // argument should be an array of Audio elements + expect(el.play).to.exist + } + }) + }) +}) diff --git a/tests/typescript-types/tsconfig.json b/tests/typescript-types/tsconfig.json new file mode 100644 index 0000000..ee06bad --- /dev/null +++ b/tests/typescript-types/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "lib": ["dom", "es2015", "es2016", "es2017"], + "target": "es2017", + "module": "esnext", + "moduleResolution": "node", + "experimentalDecorators": true, + "outDir": "dist", + "noUnusedLocals": true, + "noImplicitAny": true, + "strictNullChecks": true, + "types": ["cypress", "../../typings"] + } +} diff --git a/typings/index.d.ts b/typings/index.d.ts index bfc15bb..8de2711 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,4 +1,5 @@ // TypeScript Version: 2.8 + import { SelectorMatcherOptions, Matcher, @@ -6,32 +7,728 @@ import { getByTestId, } from 'dom-testing-library' -export namespace Cypress { - type GetByAttribute = (id: Matcher, options?: MatcherOptions) => Chainable - - type QueryByText = ( - id: Matcher, - options?: SelectorMatcherOptions, - ) => Chainable - - type AllByText = (id: Matcher, options?: SelectorMatcherOptions) => Chainable - - type GetByText = (id: Matcher, options?: SelectorMatcherOptions) => Chainable - - interface Chainable { - getByPlaceholderText: GetByAttribute - queryByText: QueryByText - queryAllByText: AllByText - getByText: GetByText - getAllByText: AllByText - queryByLabelText: QueryByText - queryAllByLabelText: AllByText - getByLabelText: GetByText - getAllByLabelText: AllByText - getByAltText: GetByAttribute - getByTestId: GetByAttribute - getByTitle: GetByAttribute - getByValue: GetByAttribute - getByTRole: GetByAttribute +declare global { + namespace Cypress { + interface Chainable { + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryByPlaceholderText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + queryByPlaceholderText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryAllByPlaceholderText( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(E | null)[]> + queryAllByPlaceholderText( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(HTMLElementTagNameMap[K] | null)[]> + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getByPlaceholderText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getByPlaceholderText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getAllByPlaceholderText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getAllByPlaceholderText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryBySelectText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + queryBySelectText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryAllBySelectText( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(E | null)[]> + queryAllBySelectText( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(HTMLElementTagNameMap[K] | null)[]> + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getBySelectText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getBySelectText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getAllBySelectText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getAllBySelectText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryByText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + queryByText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryAllByText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable<(E | null)[]> + queryAllByText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable<(HTMLElementTagNameMap[K] | null)[]> + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getByText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + getByText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getAllByText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + getAllByText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryByLabelText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + queryByLabelText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryAllByLabelText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable<(E | null)[]> + queryAllByLabelText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable<(HTMLElementTagNameMap[K] | null)[]> + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getByLabelText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + getByLabelText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getAllByLabelText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + getAllByLabelText( + id: Matcher, + options?: SelectorMatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryByAltText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + queryByAltText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryAllByAltText( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(E | null)[]> + queryAllByAltText( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(HTMLElementTagNameMap[K] | null)[]> + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getByAltText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getByAltText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getAllByAltText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getAllByAltText( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryByTestId( + id: Matcher, + options?: MatcherOptions, + ): Chainable + queryByTestId( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryAllByTestId( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(E | null)[]> + queryAllByTestId( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(HTMLElementTagNameMap[K] | null)[]> + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getByTestId( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getByTestId( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getAllByTestId( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getAllByTestId( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryByTitle( + id: Matcher, + options?: MatcherOptions, + ): Chainable + queryByTitle( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryAllByTitle( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(E | null)[]> + queryAllByTitle( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(HTMLElementTagNameMap[K] | null)[]> + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getByTitle( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getByTitle( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getAllByTitle( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getAllByTitle( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryByValue( + id: Matcher, + options?: MatcherOptions, + ): Chainable + queryByValue( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryAllByValue( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(E | null)[]> + queryAllByValue( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(HTMLElementTagNameMap[K] | null)[]> + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getByValue( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getByValue( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getAllByValue( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getAllByValue( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryByRole( + id: Matcher, + options?: MatcherOptions, + ): Chainable + queryByRole( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + queryAllByRole( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(E | null)[]> + queryAllByRole( + id: Matcher, + options?: MatcherOptions, + ): Chainable<(HTMLElementTagNameMap[K] | null)[]> + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getByRole( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getByRole( + id: Matcher, + options?: MatcherOptions, + ): Chainable + + /** + * dom-testing-library helpers for Cypress + * + * `getBy*` APIs search for an element and throw an error if nothing found + * `getAllBy*` APIs search for all elements and an error if nothing found + * `queryBy*` APIs search for an element and returns null if nothing found + * `queryAllBy*` APIs search for all elements and return empty array if nothing found + * + * @see https://github.com/kentcdodds/cypress-testing-library#usage + * @see https://github.com/kentcdodds/dom-testing-library#table-of-contents + */ + getAllByRole( + id: Matcher, + options?: MatcherOptions, + ): Chainable + getAllByRole( + id: Matcher, + options?: MatcherOptions, + ): Chainable + } } }