From 0e4a03363c76fe48035e0b891e1cb7a3baddc6dc Mon Sep 17 00:00:00 2001 From: Seb Insua Date: Fri, 30 Aug 2019 07:57:40 +0100 Subject: [PATCH] Fix testing-library__cypress by exposing @testing-library/dom#configure function (#38016) * Use prettier on testing-library__cypress * Fix testing-library__cypress by exposing @testing-library/dom#configure function --- types/testing-library__cypress/index.d.ts | 163 +++++++++--------- .../testing-library__cypress-tests.ts | 76 ++++---- types/testing-library__cypress/tslint.json | 4 - 3 files changed, 122 insertions(+), 121 deletions(-) diff --git a/types/testing-library__cypress/index.d.ts b/types/testing-library__cypress/index.d.ts index 6ae5ee63c8..5f79f8b3bf 100644 --- a/types/testing-library__cypress/index.d.ts +++ b/types/testing-library__cypress/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for @testing-library/cypress 4.1 +// Type definitions for @testing-library/cypress 4.2 // Project: https://github.com/testing-library/cypress-testing-library // Definitions by: Aaron Mc Adam // Basti Buck @@ -11,19 +11,20 @@ // TypeScript Version: 3.0 import { + configure, Matcher, MatcherOptions as DTLMatcherOptions, SelectorMatcherOptions as DTLSelectorMatcherOptions, -} from '@testing-library/dom' +} from '@testing-library/dom'; -import * as JQuery from 'jquery' +import * as JQuery from 'jquery'; export interface CTLMatcherOptions { - timeout?: number + timeout?: number; } -export type MatcherOptions = DTLMatcherOptions | CTLMatcherOptions -export type SelectorMatcherOptions = DTLSelectorMatcherOptions | CTLMatcherOptions +export type MatcherOptions = DTLMatcherOptions | CTLMatcherOptions; +export type SelectorMatcherOptions = DTLSelectorMatcherOptions | CTLMatcherOptions; declare global { namespace Cypress { @@ -42,11 +43,11 @@ declare global { queryByPlaceholderText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; queryByPlaceholderText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -62,11 +63,11 @@ declare global { queryAllByPlaceholderText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; queryAllByPlaceholderText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -82,11 +83,11 @@ declare global { getByPlaceholderText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; getByPlaceholderText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -102,11 +103,11 @@ declare global { getAllByPlaceholderText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; getAllByPlaceholderText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -122,11 +123,11 @@ declare global { queryBySelectText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; queryBySelectText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -142,11 +143,11 @@ declare global { queryAllBySelectText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; queryAllBySelectText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -159,11 +160,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getBySelectText(id: Matcher, options?: MatcherOptions): Chainable> + getBySelectText(id: Matcher, options?: MatcherOptions): Chainable>; getBySelectText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -176,11 +177,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getAllBySelectText(id: Matcher, options?: MatcherOptions): Chainable + getAllBySelectText(id: Matcher, options?: MatcherOptions): Chainable; getAllBySelectText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -196,11 +197,11 @@ declare global { queryByText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; queryByText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -216,11 +217,11 @@ declare global { queryAllByText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; queryAllByText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -236,11 +237,11 @@ declare global { getByText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; getByText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -253,11 +254,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getAllByText(id: Matcher, options?: SelectorMatcherOptions): Chainable + getAllByText(id: Matcher, options?: SelectorMatcherOptions): Chainable; getAllByText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -273,11 +274,11 @@ declare global { queryByLabelText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; queryByLabelText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -293,11 +294,11 @@ declare global { queryAllByLabelText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; queryAllByLabelText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -313,11 +314,11 @@ declare global { getByLabelText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; getByLabelText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -333,11 +334,11 @@ declare global { getAllByLabelText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable + ): Chainable; getAllByLabelText( id: Matcher, options?: SelectorMatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -350,11 +351,11 @@ 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> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -370,11 +371,11 @@ declare global { queryAllByAltText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; queryAllByAltText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -387,11 +388,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getByAltText(id: Matcher, options?: MatcherOptions): Chainable> + getByAltText(id: Matcher, options?: MatcherOptions): Chainable>; getByAltText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -404,11 +405,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getAllByAltText(id: Matcher, options?: MatcherOptions): Chainable + getAllByAltText(id: Matcher, options?: MatcherOptions): Chainable; getAllByAltText( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -421,11 +422,11 @@ 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> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -438,11 +439,11 @@ 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> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -455,11 +456,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getByTestId(id: Matcher, options?: MatcherOptions): Chainable> + getByTestId(id: Matcher, options?: MatcherOptions): Chainable>; getByTestId( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -472,11 +473,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getAllByTestId(id: Matcher, options?: MatcherOptions): Chainable + getAllByTestId(id: Matcher, options?: MatcherOptions): Chainable; getAllByTestId( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -489,11 +490,11 @@ 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> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -506,11 +507,11 @@ 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> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -523,11 +524,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getByTitle(id: Matcher, options?: MatcherOptions): Chainable> + getByTitle(id: Matcher, options?: MatcherOptions): Chainable>; getByTitle( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -540,11 +541,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getAllByTitle(id: Matcher, options?: MatcherOptions): Chainable + getAllByTitle(id: Matcher, options?: MatcherOptions): Chainable; getAllByTitle( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -560,11 +561,11 @@ declare global { queryByDisplayValue( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; queryByDisplayValue( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -580,11 +581,11 @@ declare global { queryAllByDisplayValue( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; queryAllByDisplayValue( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -600,11 +601,11 @@ declare global { getByDisplayValue( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; getByDisplayValue( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -617,11 +618,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getAllByDisplayValue(id: Matcher, options?: MatcherOptions): Chainable + getAllByDisplayValue(id: Matcher, options?: MatcherOptions): Chainable; getAllByDisplayValue( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -634,11 +635,11 @@ 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> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -651,11 +652,11 @@ 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> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -668,11 +669,11 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getByRole(id: Matcher, options?: MatcherOptions): Chainable> + getByRole(id: Matcher, options?: MatcherOptions): Chainable>; getByRole( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; /** * dom-testing-library helpers for Cypress @@ -685,14 +686,16 @@ declare global { * @see https://github.com/testing-library/cypress-testing-library#usage * @see https://github.com/testing-library/dom-testing-library#table-of-contents */ - getAllByRole(id: Matcher, options?: MatcherOptions): Chainable + getAllByRole(id: Matcher, options?: MatcherOptions): Chainable; getAllByRole( id: Matcher, options?: MatcherOptions, - ): Chainable> + ): Chainable>; } } } -declare const Cypress: Cypress.Chainable -export default Cypress +declare const Cypress: Cypress.Chainable; +export default Cypress; + +export { configure }; diff --git a/types/testing-library__cypress/testing-library__cypress-tests.ts b/types/testing-library__cypress/testing-library__cypress-tests.ts index 17058fb350..b3d4c7f41c 100644 --- a/types/testing-library__cypress/testing-library__cypress-tests.ts +++ b/types/testing-library__cypress/testing-library__cypress-tests.ts @@ -1,45 +1,47 @@ -import Cypress from '@testing-library/cypress' +import Cypress, { configure } from '@testing-library/cypress'; + +configure({ testIdAttribute: 'data-myown-testid' }); // getBy* -Cypress.getByPlaceholderText('foo') -Cypress.getBySelectText('foo') -Cypress.getByText('foo') -Cypress.getByLabelText('foo') -Cypress.getByAltText('foo') -Cypress.getByTestId('foo') -Cypress.getByTitle('foo') -Cypress.getByDisplayValue('foo') -Cypress.getByRole('foo') +Cypress.getByPlaceholderText('foo'); +Cypress.getBySelectText('foo'); +Cypress.getByText('foo'); +Cypress.getByLabelText('foo'); +Cypress.getByAltText('foo'); +Cypress.getByTestId('foo'); +Cypress.getByTitle('foo'); +Cypress.getByDisplayValue('foo'); +Cypress.getByRole('foo'); // getAllBy* -Cypress.getAllByPlaceholderText('foo') -Cypress.getAllBySelectText('foo') -Cypress.getAllByText('foo') -Cypress.getAllByLabelText('foo') -Cypress.getAllByAltText('foo') -Cypress.getAllByTestId('foo') -Cypress.getAllByTitle('foo') -Cypress.getAllByDisplayValue('foo') -Cypress.getAllByRole('foo') +Cypress.getAllByPlaceholderText('foo'); +Cypress.getAllBySelectText('foo'); +Cypress.getAllByText('foo'); +Cypress.getAllByLabelText('foo'); +Cypress.getAllByAltText('foo'); +Cypress.getAllByTestId('foo'); +Cypress.getAllByTitle('foo'); +Cypress.getAllByDisplayValue('foo'); +Cypress.getAllByRole('foo'); // queryBy* -Cypress.queryByPlaceholderText('foo') -Cypress.queryBySelectText('foo') -Cypress.queryByText('foo') -Cypress.queryByLabelText('foo') -Cypress.queryByAltText('foo') -Cypress.queryByTestId('foo') -Cypress.queryByTitle('foo') -Cypress.queryByDisplayValue('foo') -Cypress.queryByRole('foo') +Cypress.queryByPlaceholderText('foo'); +Cypress.queryBySelectText('foo'); +Cypress.queryByText('foo'); +Cypress.queryByLabelText('foo'); +Cypress.queryByAltText('foo'); +Cypress.queryByTestId('foo'); +Cypress.queryByTitle('foo'); +Cypress.queryByDisplayValue('foo'); +Cypress.queryByRole('foo'); // queryAllBy* -Cypress.queryAllByPlaceholderText('foo') -Cypress.queryAllBySelectText('foo') -Cypress.queryAllByText('foo') -Cypress.queryAllByLabelText('foo') -Cypress.queryAllByAltText('foo') -Cypress.queryAllByTestId('foo') -Cypress.queryAllByTitle('foo') -Cypress.queryAllByDisplayValue('foo') -Cypress.queryAllByRole('foo') +Cypress.queryAllByPlaceholderText('foo'); +Cypress.queryAllBySelectText('foo'); +Cypress.queryAllByText('foo'); +Cypress.queryAllByLabelText('foo'); +Cypress.queryAllByAltText('foo'); +Cypress.queryAllByTestId('foo'); +Cypress.queryAllByTitle('foo'); +Cypress.queryAllByDisplayValue('foo'); +Cypress.queryAllByRole('foo'); diff --git a/types/testing-library__cypress/tslint.json b/types/testing-library__cypress/tslint.json index bf034b1408..9dc1c6ec6c 100644 --- a/types/testing-library__cypress/tslint.json +++ b/types/testing-library__cypress/tslint.json @@ -1,10 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "semicolon": [ - true, - "never" - ], "whitespace": [ false ],