diff --git a/types/testing-library__cypress/index.d.ts b/types/testing-library__cypress/index.d.ts index 56ecd4c726..6f68ec231c 100644 --- a/types/testing-library__cypress/index.d.ts +++ b/types/testing-library__cypress/index.d.ts @@ -17,11 +17,9 @@ import { SelectorMatcherOptions as DTLSelectorMatcherOptions, } from '@testing-library/dom'; -import * as JQuery from 'jquery'; - export interface CTLMatcherOptions { timeout?: number; - container?: JQuery; + container?: HTMLElement | JQuery; } export type MatcherOptions = DTLMatcherOptions | CTLMatcherOptions; @@ -41,14 +39,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryByPlaceholderText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; - queryByPlaceholderText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryByPlaceholderText(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -61,14 +52,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryAllByPlaceholderText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; - queryAllByPlaceholderText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryAllByPlaceholderText(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -81,14 +65,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findByPlaceholderText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; - findByPlaceholderText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findByPlaceholderText(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -101,14 +78,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findAllByPlaceholderText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; - findAllByPlaceholderText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findAllByPlaceholderText(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -121,14 +91,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryByText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; - queryByText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; + queryByText(id: Matcher, options?: SelectorMatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -141,14 +104,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryAllByText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; - queryAllByText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; + queryAllByText(id: Matcher, options?: SelectorMatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -161,14 +117,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findByText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; - findByText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; + findByText(id: Matcher, options?: SelectorMatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -181,11 +130,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findAllByText(id: Matcher, options?: SelectorMatcherOptions): Chainable; - findAllByText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; + findAllByText(id: Matcher, options?: SelectorMatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -198,14 +143,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryByLabelText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; - queryByLabelText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; + queryByLabelText(id: Matcher, options?: SelectorMatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -218,14 +156,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryAllByLabelText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; - queryAllByLabelText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; + queryAllByLabelText(id: Matcher, options?: SelectorMatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -238,14 +169,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findByLabelText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; - findByLabelText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; + findByLabelText(id: Matcher, options?: SelectorMatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -258,14 +182,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findAllByLabelText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable; - findAllByLabelText( - id: Matcher, - options?: SelectorMatcherOptions, - ): Chainable>; + findAllByLabelText(id: Matcher, options?: SelectorMatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -278,11 +195,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryByAltText(id: Matcher, options?: MatcherOptions): Chainable>; - queryByAltText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryByAltText(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -295,14 +208,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryAllByAltText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; - queryAllByAltText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryAllByAltText(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -315,11 +221,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findByAltText(id: Matcher, options?: MatcherOptions): Chainable>; - findByAltText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findByAltText(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -332,11 +234,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findAllByAltText(id: Matcher, options?: MatcherOptions): Chainable; - findAllByAltText( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findAllByAltText(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -349,11 +247,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryByTestId(id: Matcher, options?: MatcherOptions): Chainable>; - queryByTestId( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryByTestId(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -366,11 +260,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryAllByTestId(id: Matcher, options?: MatcherOptions): Chainable>; - queryAllByTestId( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryAllByTestId(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -383,11 +273,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findByTestId(id: Matcher, options?: MatcherOptions): Chainable>; - findByTestId( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findByTestId(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -400,11 +286,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findAllByTestId(id: Matcher, options?: MatcherOptions): Chainable; - findAllByTestId( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findAllByTestId(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -417,11 +299,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryByTitle(id: Matcher, options?: MatcherOptions): Chainable>; - queryByTitle( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryByTitle(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -434,11 +312,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryAllByTitle(id: Matcher, options?: MatcherOptions): Chainable>; - queryAllByTitle( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryAllByTitle(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -451,11 +325,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findByTitle(id: Matcher, options?: MatcherOptions): Chainable>; - findByTitle( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findByTitle(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -468,11 +338,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findAllByTitle(id: Matcher, options?: MatcherOptions): Chainable; - findAllByTitle( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findAllByTitle(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -485,14 +351,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryByDisplayValue( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; - queryByDisplayValue( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryByDisplayValue(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -505,14 +364,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryAllByDisplayValue( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; - queryAllByDisplayValue( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryAllByDisplayValue(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -525,14 +377,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findByDisplayValue( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; - findByDisplayValue( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findByDisplayValue(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -545,11 +390,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findAllByDisplayValue(id: Matcher, options?: MatcherOptions): Chainable; - findAllByDisplayValue( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findAllByDisplayValue(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -562,11 +403,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryByRole(id: Matcher, options?: MatcherOptions): Chainable>; - queryByRole( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryByRole(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -579,11 +416,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - queryAllByRole(id: Matcher, options?: MatcherOptions): Chainable>; - queryAllByRole( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + queryAllByRole(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -596,11 +429,7 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findByRole(id: Matcher, options?: MatcherOptions): Chainable>; - findByRole( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findByRole(id: Matcher, options?: MatcherOptions): Chainable; /** * dom-testing-library helpers for Cypress @@ -613,16 +442,9 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - findAllByRole(id: Matcher, options?: MatcherOptions): Chainable; - findAllByRole( - id: Matcher, - options?: MatcherOptions, - ): Chainable>; + findAllByRole(id: Matcher, options?: MatcherOptions): Chainable; } } } -declare const Cypress: Cypress.Chainable; -export default Cypress; - export { configure }; diff --git a/types/testing-library__cypress/package.json b/types/testing-library__cypress/package.json new file mode 100644 index 0000000000..3d2be4c538 --- /dev/null +++ b/types/testing-library__cypress/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "cypress": "^3.5.0" + } +} diff --git a/types/testing-library__cypress/testing-library__cypress-tests.ts b/types/testing-library__cypress/testing-library__cypress-tests.ts index 09231b5057..fb84164be2 100644 --- a/types/testing-library__cypress/testing-library__cypress-tests.ts +++ b/types/testing-library__cypress/testing-library__cypress-tests.ts @@ -1,43 +1,51 @@ -import Cypress, { configure } from '@testing-library/cypress'; +/// +import { configure } from '@testing-library/cypress'; configure({ testIdAttribute: 'data-myown-testid' }); // findBy* -Cypress.findByPlaceholderText('foo'); -Cypress.findByText('foo'); -Cypress.findByLabelText('foo'); -Cypress.findByAltText('foo'); -Cypress.findByTestId('foo'); -Cypress.findByTitle('foo'); -Cypress.findByDisplayValue('foo'); -Cypress.findByRole('foo'); +cy.findByPlaceholderText('foo'); // $ExpectType Chainable> +cy.findByText('foo'); // $ExpectType Chainable> +cy.findByLabelText('foo'); // $ExpectType Chainable> +cy.findByAltText('foo'); // $ExpectType Chainable> +cy.findByTestId('foo'); // $ExpectType Chainable> +cy.findByTitle('foo'); // $ExpectType Chainable> +cy.findByDisplayValue('foo'); // $ExpectType Chainable> +cy.findByRole('foo'); // $ExpectType Chainable> // findAllBy* -Cypress.findAllByPlaceholderText('foo'); -Cypress.findAllByText('foo'); -Cypress.findAllByLabelText('foo'); -Cypress.findAllByAltText('foo'); -Cypress.findAllByTestId('foo'); -Cypress.findAllByTitle('foo'); -Cypress.findAllByDisplayValue('foo'); -Cypress.findAllByRole('foo'); +cy.findAllByPlaceholderText('foo'); // $ExpectType Chainable> +cy.findAllByText('foo'); // $ExpectType Chainable> +cy.findAllByLabelText('foo'); // $ExpectType Chainable> +cy.findAllByAltText('foo'); // $ExpectType Chainable> +cy.findAllByTestId('foo'); // $ExpectType Chainable> +cy.findAllByTitle('foo'); // $ExpectType Chainable> +cy.findAllByDisplayValue('foo'); // $ExpectType Chainable> +cy.findAllByRole('foo'); // $ExpectType Chainable> // queryBy* -Cypress.queryByPlaceholderText('foo'); -Cypress.queryByText('foo'); -Cypress.queryByLabelText('foo'); -Cypress.queryByAltText('foo'); -Cypress.queryByTestId('foo'); -Cypress.queryByTitle('foo'); -Cypress.queryByDisplayValue('foo'); -Cypress.queryByRole('foo'); +cy.queryByPlaceholderText('foo'); // $ExpectType Chainable> +cy.queryByText('foo'); // $ExpectType Chainable> +cy.queryByLabelText('foo'); // $ExpectType Chainable> +cy.queryByAltText('foo'); // $ExpectType Chainable> +cy.queryByTestId('foo'); // $ExpectType Chainable> +cy.queryByTitle('foo'); // $ExpectType Chainable> +cy.queryByDisplayValue('foo'); // $ExpectType Chainable> +cy.queryByRole('foo'); // $ExpectType Chainable> // queryAllBy* -Cypress.queryAllByPlaceholderText('foo'); -Cypress.queryAllByText('foo'); -Cypress.queryAllByLabelText('foo'); -Cypress.queryAllByAltText('foo'); -Cypress.queryAllByTestId('foo'); -Cypress.queryAllByTitle('foo'); -Cypress.queryAllByDisplayValue('foo'); -Cypress.queryAllByRole('foo'); +cy.queryAllByPlaceholderText('foo'); // $ExpectType Chainable> +cy.queryAllByText('foo'); // $ExpectType Chainable> +cy.queryAllByLabelText('foo'); // $ExpectType Chainable> +cy.queryAllByAltText('foo'); // $ExpectType Chainable> +cy.queryAllByTestId('foo'); // $ExpectType Chainable> +cy.queryAllByTitle('foo'); // $ExpectType Chainable> +cy.queryAllByDisplayValue('foo'); // $ExpectType Chainable> +cy.queryAllByRole('foo'); // $ExpectType Chainable> + +// with container option +const container = document.createElement('div'); +cy.queryAllByRole('foo', { container }); // $ExpectType Chainable> + +const $container = cy.$$('body').append('div'); +cy.queryAllByRole('foo', { container: $container }); // $ExpectType Chainable> diff --git a/types/testing-library__cypress/tslint.json b/types/testing-library__cypress/tslint.json index 9dc1c6ec6c..f93cf8562a 100644 --- a/types/testing-library__cypress/tslint.json +++ b/types/testing-library__cypress/tslint.json @@ -1,9 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "whitespace": [ - false - ], - "no-unnecessary-generics": false - } + "extends": "dtslint/dt.json" }