Skip to content

Commit 67106ba

Browse files
authored
feat: update @testing-library/dom to 7 (#30)
BREAKING CHANGE: updated to new major versions of @testing-library/dom and wait-for-expect
1 parent ff5e32b commit 67106ba

File tree

9 files changed

+768
-766
lines changed

9 files changed

+768
-766
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ node_js:
88
- v12
99
- v10
1010
env:
11-
- PPTR_OVERRIDE_VERSION=1.5.x
12-
- PPTR_OVERRIDE_VERSION=1.7.x
11+
- PPTR_OVERRIDE_VERSION=1.6.x
12+
- PPTR_OVERRIDE_VERSION=1.8.x
1313
- PPTR_OVERRIDE_VERSION=1.12.x
1414
- PPTR_OVERRIDE_VERSION=latest
1515
before_install:
1616
- npm install -g yarn coveralls nyc @patrickhulce/scripts
1717
before_script:
18-
- yarn add -D "puppeteer@${PPTR_OVERRIDE_VERSION}"
18+
- yarn add -D "puppeteer@${PPTR_OVERRIDE_VERSION}" "@types/puppeteer@${PPTR_OVERRIDE_VERSION}"
1919
script:
2020
- yarn rebuild
2121
- yarn test:lint

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
[![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)
66
[![Dependencies](https://david-dm.org/testing-library/pptr-testing-library.svg)](https://david-dm.org/testing-library/pptr-testing-library)
77

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

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

1212
## Install
1313

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

5757
## API
5858

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

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

6364
---
6465

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

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

9696
## Known Limitations
9797

98-
- `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).
98+
- `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).
9999
- `fireEvent` method is not exposed, use puppeteer's built-ins instead.
100100
- `expect` assertion extensions are not available.
101101

102102
## Special Thanks
103103

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

106106
## Related Puppeteer Test Utilities
107107

lib/extend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ElementHandle} from '../node_modules/@types/puppeteer'
1+
import {ElementHandle} from 'puppeteer'
22

33
import {getDocument, getQueriesForElement} from '.'
44
import {IScopedQueryUtils} from './typedefs'

lib/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ export async function getDocument(_page?: Page): Promise<ElementHandle> {
124124
}
125125

126126
export function wait(
127-
callback: () => any = () => undefined,
128-
{timeout = 4500, interval = 50} = {}, // tslint:disable-line
127+
callback: () => void,
128+
{timeout = 4500, interval = 50}: {timeout?: number; interval?: number} = {},
129129
): Promise<{}> {
130130
return waitForExpect(callback, timeout, interval)
131131
}

lib/typedefs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Matcher, MatcherOptions, SelectorMatcherOptions} from 'dom-testing-library/typings' // tslint:disable-line no-submodule-imports
1+
import {Matcher, MatcherOptions, SelectorMatcherOptions} from '@testing-library/dom'
22
import {ElementHandle} from 'puppeteer'
33

44
type Element = ElementHandle

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"keywords": [
2929
"puppeteer",
3030
"dom-testing-library",
31+
"testing-library",
3132
"testing",
3233
"utility"
3334
],
@@ -55,8 +56,8 @@
5556
}
5657
},
5758
"dependencies": {
58-
"dom-testing-library": "^4.1.1",
59-
"wait-for-expect": "^1.2.0"
59+
"@testing-library/dom": "^7.0.4",
60+
"wait-for-expect": "^3.0.2"
6061
},
6162
"devDependencies": {
6263
"@patrickhulce/lint": "^2.1.3",

rollup.input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from 'dom-testing-library/dist/queries'
2-
export {getNodeText} from 'dom-testing-library/dist/get-node-text'
1+
export * from '@testing-library/dom/dist/queries'
2+
export {getNodeText} from '@testing-library/dom'

test/extend.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ describe('lib/extend.ts', () => {
5656
await scope!.getByTitle('missing')
5757
fail()
5858
} catch (err) {
59-
err.message = err.message.replace(/(\s*at .*(\n|$))+/gm, '\n <stack>:X:X')
59+
err.message = err.message
60+
.replace(/(\s*at .*(\n|$))+/gm, '\n <stack>:X:X')
61+
.replace('TestingLibraryElementError', 'Error') // Puppeteer 1.7 returns a generic error
6062
expect(err.message).toMatchSnapshot()
6163
}
6264
})

0 commit comments

Comments
 (0)