Skip to content
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ node_js:
- v12
- v10
env:
- PPTR_OVERRIDE_VERSION=1.5.x
- PPTR_OVERRIDE_VERSION=1.7.x
- PPTR_OVERRIDE_VERSION=1.6.x
- PPTR_OVERRIDE_VERSION=1.8.x
- PPTR_OVERRIDE_VERSION=1.12.x
- PPTR_OVERRIDE_VERSION=latest
before_install:
- npm install -g yarn coveralls nyc @patrickhulce/scripts
before_script:
- yarn add -D "puppeteer@${PPTR_OVERRIDE_VERSION}"
- yarn add -D "puppeteer@${PPTR_OVERRIDE_VERSION}" "@types/puppeteer@${PPTR_OVERRIDE_VERSION}"
script:
- yarn rebuild
- yarn test:lint
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
[![Coverage Status](https://coveralls.io/repos/github/testing-library/pptr-testing-library/badge.svg?branch=master)](https://coveralls.io/github/testing-library/pptr-testing-library?branch=master)
[![Dependencies](https://david-dm.org/testing-library/pptr-testing-library.svg)](https://david-dm.org/testing-library/pptr-testing-library)

[puppeteer](https://github.com/GoogleChrome/puppeteer) + [dom-testing-library](https://github.com/testing-library/dom-testing-library) = 💖
[puppeteer](https://github.com/GoogleChrome/puppeteer) + [@testing-library/dom](https://github.com/testing-library/dom-testing-library) = 💖

All your favorite user-centric querying functions from react-testing-library/dom-testing-library available from Puppeteer!
All your favorite user-centric querying functions from @testing-library/react & @testing-library/library available from Puppeteer!

## Install

Expand Down Expand Up @@ -56,18 +56,18 @@ const {getByText} = $form.getQueriesForElement()

## API

Unique methods, not part of `dom-testing-library`
Unique methods, not part of `@testing-library/dom`

- `getDocument(page: puppeteer.Page): ElementHandle` - get an ElementHandle for the document
- `wait(conditionFn: () => {}): Promise<{}>` - wait for the condition to not throw (wrapper around `waitForExpect`)

---

[dom-testing-libary API](https://github.com/testing-library/dom-testing-library#usage). All `get*`/`query*` methods are supported.
[@testing-library/dom API](https://github.com/testing-library/dom-testing-library#usage). All `get*`/`query*` methods are supported.

- `getQueriesForElement(handle: ElementHandle): ElementHandle & QueryUtils` - extend the input object with the query API and return it
- `wait(conditionFn: () => {}): Promise<{}>` - wait for the condition to not throw
- `getNodeText(handle: ElementHandle): Promise<string>` - get the text content of the element
- `queries: QueryUtils` - the query subset of `dom-testing-library` exports
- `queries: QueryUtils` - the query subset of `@testing-library/dom` exports
- `queryByPlaceholderText`
- `queryAllByPlaceholderText`
- `getByPlaceholderText`
Expand Down Expand Up @@ -95,13 +95,13 @@ Unique methods, not part of `dom-testing-library`

## Known Limitations

- `waitForElement` method is not exposed. Puppeteer has its own set of wait utilities that somewhat conflict with the style used in `dom-testing-library`. See [#3](https://github.com/testing-library/pptr-testing-library/issues/3).
- `waitForElement` method is not exposed. Puppeteer has its own set of wait utilities that somewhat conflict with the style used in `@testing-library/dom`. See [#3](https://github.com/testing-library/pptr-testing-library/issues/3).
- `fireEvent` method is not exposed, use puppeteer's built-ins instead.
- `expect` assertion extensions are not available.

## Special Thanks

[dom-testing-library](https://github.com/testing-library/dom-testing-library) of course!
[@testing-library/dom](https://github.com/testing-library/dom-testing-library) of course!

## Related Puppeteer Test Utilities

Expand Down
2 changes: 1 addition & 1 deletion lib/extend.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ElementHandle} from '../node_modules/@types/puppeteer'
import {ElementHandle} from 'puppeteer'

import {getDocument, getQueriesForElement} from '.'
import {IScopedQueryUtils} from './typedefs'
Expand Down
4 changes: 2 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export async function getDocument(_page?: Page): Promise<ElementHandle> {
}

export function wait(
callback: () => any = () => undefined,
{timeout = 4500, interval = 50} = {}, // tslint:disable-line
callback: () => void,
{timeout = 4500, interval = 50}: {timeout?: number; interval?: number} = {},
): Promise<{}> {
return waitForExpect(callback, timeout, interval)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/typedefs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Matcher, MatcherOptions, SelectorMatcherOptions} from 'dom-testing-library/typings' // tslint:disable-line no-submodule-imports
import {Matcher, MatcherOptions, SelectorMatcherOptions} from '@testing-library/dom'
import {ElementHandle} from 'puppeteer'

type Element = ElementHandle
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"keywords": [
"puppeteer",
"dom-testing-library",
"testing-library",
"testing",
"utility"
],
Expand Down Expand Up @@ -55,8 +56,8 @@
}
},
"dependencies": {
"dom-testing-library": "^4.1.1",
"wait-for-expect": "^1.2.0"
"@testing-library/dom": "^7.0.4",
"wait-for-expect": "^3.0.2"
},
"devDependencies": {
"@patrickhulce/lint": "^2.1.3",
Expand Down
4 changes: 2 additions & 2 deletions rollup.input.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from 'dom-testing-library/dist/queries'
export {getNodeText} from 'dom-testing-library/dist/get-node-text'
export * from '@testing-library/dom/dist/queries'
export {getNodeText} from '@testing-library/dom'
4 changes: 3 additions & 1 deletion test/extend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ describe('lib/extend.ts', () => {
await scope!.getByTitle('missing')
fail()
} catch (err) {
err.message = err.message.replace(/(\s*at .*(\n|$))+/gm, '\n <stack>:X:X')
err.message = err.message
.replace(/(\s*at .*(\n|$))+/gm, '\n <stack>:X:X')
.replace('TestingLibraryElementError', 'Error') // Puppeteer 1.7 returns a generic error
expect(err.message).toMatchSnapshot()
}
})
Expand Down
Loading