-
Notifications
You must be signed in to change notification settings - Fork 154
Move types from DefinitelyTyped #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kentcdodds
merged 7 commits into
testing-library:next
from
TheGallery:pr/migrate-ts-types-internally
Aug 22, 2020
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f439ea1
Move type declarations from DefinitelyTyped
TheGallery a893d30
Remove semicolons
TheGallery 06f8132
Update README
TheGallery 25f26b0
Update package.json
kentcdodds d91872c
Remove types for depracated queries
TheGallery 6e13495
Add typescript as a dev dependency
TheGallery 0985150
Merge branch 'next' into pr/migrate-ts-types-internally
kentcdodds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Allow `import '@testing-library/cypress/add-commands'` from a `cypress/commands.ts` file | ||
import './' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
// TypeScript Version: 3.8 | ||
|
||
import { | ||
configure, | ||
Matcher, | ||
MatcherOptions as DTLMatcherOptions, | ||
ByRoleOptions as DTLByRoleOptions, | ||
SelectorMatcherOptions as DTLSelectorMatcherOptions, | ||
} from '@testing-library/dom' | ||
|
||
export interface CTLMatcherOptions { | ||
timeout?: number | ||
container?: HTMLElement | JQuery | ||
} | ||
|
||
export type MatcherOptions = DTLMatcherOptions | CTLMatcherOptions | ||
export type ByRoleOptions = DTLByRoleOptions | CTLMatcherOptions | ||
export type SelectorMatcherOptions = DTLSelectorMatcherOptions | CTLMatcherOptions | ||
|
||
declare global { | ||
namespace Cypress { | ||
interface Chainable<Subject = any> { | ||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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?: ByRoleOptions): Chainable<JQuery> | ||
|
||
/** | ||
* dom-testing-library helpers for Cypress | ||
* | ||
* `findBy*` APIs search for an element and throw an error if nothing found | ||
* `findAllBy*` APIs search for all elements and an error if nothing found | ||
* | ||
* @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?: ByRoleOptions): Chainable<JQuery> | ||
} | ||
} | ||
} | ||
|
||
export { configure } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/// <reference types="Cypress" /> | ||
import { configure } from '@testing-library/cypress' | ||
import '@testing-library/cypress/add-commands' | ||
|
||
configure({ testIdAttribute: 'data-myown-testid' }) | ||
|
||
// findBy* | ||
cy.findByPlaceholderText('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findByText('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findByLabelText('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findByAltText('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findByTestId('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findByTitle('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findByDisplayValue('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findByRole('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
|
||
// findAllBy* | ||
cy.findAllByPlaceholderText('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findAllByText('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findAllByLabelText('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findAllByAltText('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findAllByTestId('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findAllByTitle('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findAllByDisplayValue('foo') // $ExpectType Chainable<JQuery<HTMLElement>> | ||
cy.findAllByRole('foo') // $ExpectType Chainable<JQuery<HTMLElement>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": ["es6", "dom"], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"baseUrl": ".", | ||
"noEmit": true, | ||
"types": [], | ||
"paths": { | ||
"@testing-library/cypress": ["."] | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": ["dtslint/dtslint.json"], | ||
"rules": { | ||
"no-useless-files": false, | ||
"no-relative-import-in-test": false, | ||
"semicolon": false, | ||
"whitespace": false | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added as a dependency because
dtslint
complains without it.