Skip to content

WIP: chore(typescript): add TypeScript typings #16

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
merged 2 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0-semantically-released",
"description": "Simple and complete custom Cypress commands and utilities that encourage good testing practices.",
"main": "dist/index.js",
"typings": "typings",
"engines": {
"node": "> 6"
},
Expand All @@ -20,7 +21,8 @@
"test:cypress:dev": "npm-run-all --silent --parallel --race test:cypress:serve test:cypress:open",
"validate": "kcd-scripts validate build,lint,test",
"setup": "npm install && npm run validate -s",
"precommit": "kcd-scripts precommit"
"precommit": "kcd-scripts precommit",
"dtslint": "dtslint typings"
},
"files": [
"dist",
Expand All @@ -43,6 +45,7 @@
},
"devDependencies": {
"cypress": "^3.0.1",
"dtslint": "^0.3.0",
"kcd-scripts": "^0.37.0",
"npm-run-all": "^4.1.2",
"serve": "^10.0.0",
Expand Down
37 changes: 37 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// TypeScript Version: 2.8
import {
SelectorMatcherOptions,
Matcher,
MatcherOptions,
getByTestId,
} from 'dom-testing-library'

export namespace Cypress {
type GetByAttribute = (id: Matcher, options?: MatcherOptions) => Chainable
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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
}
}
14 changes: 14 additions & 0 deletions typings/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"noEmit": true,

"baseUrl": ".",
"paths": {"cypress-testing-library": ["."]}
}
}
7 changes: 7 additions & 0 deletions typings/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"semicolon": [true, "never"],
"whitespace": [false]
}
}