Skip to content

Commit 1727a49

Browse files
TolseeKent C. Dodds
authored andcommitted
feat(waitForElementToBeRemoved): add the new utility function (#218)
* Add tests and snapshots * Implement waitForElementToBeRemoved method * Export waitForElementToBeRemoved * Add as contributor * Update README.md after rebase * Throw error is the element is not present in the first place * Add test for full coverage * User jest time faker * Add typings * Cleanup * Update snapshot * Get rid of iife * Cleanup from review * Check for empty array as well * Check for error, falsy and empty to check whether the element is removed * error not defined error fix * Change snapshot to inline snapshot * Update snapshot * Only observe mutations if synchronous test passes * only observer if synchronous test passes fix * Await for the respective promise to resolve in test * Snapshot test to normal toHaveBeenCalledWith assertions * Update comment * Remove comment * test: improve tests for wait-for-element-to-be-removed * test: fix everything * test: do not test unstable node versions
1 parent ca7db36 commit 1727a49

24 files changed

+186
-104
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,15 @@
498498
"code",
499499
"test"
500500
]
501+
},
502+
{
503+
"login": "Tolsee",
504+
"name": "Tulsi Sapkota",
505+
"avatar_url": "https://avatars0.githubusercontent.com/u/16590492?v=4",
506+
"profile": "https://github.com/Tolsee",
507+
"contributions": [
508+
"code"
509+
]
501510
}
502511
]
503512
}

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ cache:
66
notifications:
77
email: false
88
node_js:
9-
- 'node'
109
- '10'
1110
- '8'
1211
install: npm install

CONTRIBUTING.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,6 @@ Thanks for being willing to contribute!
2727
> branch. Whenever you want to update your version of `master`, do a regular
2828
> `git pull`.
2929
30-
## Add yourself as a contributor
31-
32-
This project follows the [all contributors][all-contributors] specification.
33-
To add yourself to the table of contributors on the `README.md`, please use the
34-
automated script as part of your PR:
35-
36-
```console
37-
npm run add-contributor
38-
```
39-
40-
Follow the prompt and commit `.all-contributorsrc` and `README.md` in the PR.
41-
If you've already added yourself to the list and are making
42-
a new type of contribution, you can run it again and select the added
43-
contribution type.
44-
4530
## Committing and Pushing changes
4631
4732
Please make sure to run the tests before you commit your changes. You can run

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
[![downloads][downloads-badge]][npmtrends]
2121
[![MIT License][license-badge]][license]
2222

23-
[![All Contributors](https://img.shields.io/badge/all_contributors-50-orange.svg?style=flat-square)](#contributors)
23+
[![All Contributors](https://img.shields.io/badge/all_contributors-51-orange.svg?style=flat-square)](#contributors)
2424
[![PRs Welcome][prs-badge]][prs]
2525
[![Code of Conduct][coc-badge]][coc]
2626

@@ -138,7 +138,7 @@ Thanks goes to these people ([emoji key][emojis]):
138138
| [<img src="https://avatars3.githubusercontent.com/u/881986?v=4" width="100px;" alt="dadamssg"/><br /><sub><b>dadamssg</b></sub>](https://github.com/dadamssg)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=dadamssg "Code") | [<img src="https://avatars1.githubusercontent.com/u/186971?v=4" width="100px;" alt="Neil Kistner"/><br /><sub><b>Neil Kistner</b></sub>](https://neilkistner.com/)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=wyze "Code") | [<img src="https://avatars3.githubusercontent.com/u/1448597?v=4" width="100px;" alt="Ben Chauvette"/><br /><sub><b>Ben Chauvette</b></sub>](http://bdchauvette.net/)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=bdchauvette "Code") | [<img src="https://avatars2.githubusercontent.com/u/777527?v=4" width="100px;" alt="Jeff Baumgardt"/><br /><sub><b>Jeff Baumgardt</b></sub>](https://github.com/JeffBaumgardt)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=JeffBaumgardt "Code") [📖](https://github.com/kentcdodds/dom-testing-library/commits?author=JeffBaumgardt "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/4658208?v=4" width="100px;" alt="Matan Kushner"/><br /><sub><b>Matan Kushner</b></sub>](http://matchai.me)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=matchai "Code") [📖](https://github.com/kentcdodds/dom-testing-library/commits?author=matchai "Documentation") [🤔](#ideas-matchai "Ideas, Planning, & Feedback") [⚠️](https://github.com/kentcdodds/dom-testing-library/commits?author=matchai "Tests") | [<img src="https://avatars2.githubusercontent.com/u/5779538?v=4" width="100px;" alt="Alex Wendte"/><br /><sub><b>Alex Wendte</b></sub>](http://www.wendtedesigns.com/)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=themostcolm "Code") [📖](https://github.com/kentcdodds/dom-testing-library/commits?author=themostcolm "Documentation") [⚠️](https://github.com/kentcdodds/dom-testing-library/commits?author=themostcolm "Tests") | [<img src="https://avatars0.githubusercontent.com/u/2196208?v=4" width="100px;" alt="Tamas Fodor"/><br /><sub><b>Tamas Fodor</b></sub>](https://github.com/ruffle1986)<br />[📖](https://github.com/kentcdodds/dom-testing-library/commits?author=ruffle1986 "Documentation") |
139139
| [<img src="https://avatars3.githubusercontent.com/u/14793495?v=4" width="100px;" alt="Benjamin Eckardt"/><br /><sub><b>Benjamin Eckardt</b></sub>](https://github.com/BenjaminEckardt)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=BenjaminEckardt "Code") | [<img src="https://avatars3.githubusercontent.com/u/205752?v=4" width="100px;" alt="Ryan Campbell"/><br /><sub><b>Ryan Campbell</b></sub>](https://github.com/campbellr)<br />[📖](https://github.com/kentcdodds/dom-testing-library/commits?author=campbellr "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/1335519?v=4" width="100px;" alt="Taylor Briggs"/><br /><sub><b>Taylor Briggs</b></sub>](https://taylor-briggs.com)<br />[⚠️](https://github.com/kentcdodds/dom-testing-library/commits?author=TaylorBriggs "Tests") | [<img src="https://avatars2.githubusercontent.com/u/132233?v=4" width="100px;" alt="John Gozde"/><br /><sub><b>John Gozde</b></sub>](https://github.com/jgoz)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=jgoz "Code") | [<img src="https://avatars2.githubusercontent.com/u/3382565?v=4" width="100px;" alt="C. T. Lin"/><br /><sub><b>C. T. Lin</b></sub>](https://github.com/chentsulin)<br />[📖](https://github.com/kentcdodds/dom-testing-library/commits?author=chentsulin "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/5312329?v=4" width="100px;" alt="Terrence Wong"/><br /><sub><b>Terrence Wong</b></sub>](http://terrencewwong.com)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=terrencewwong "Code") | [<img src="https://avatars0.githubusercontent.com/u/12230408?v=4" width="100px;" alt="Soo Jae Hwang"/><br /><sub><b>Soo Jae Hwang</b></sub>](https://www.ossfinder.com)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=misoguy "Code") |
140140
| [<img src="https://avatars0.githubusercontent.com/u/19773?v=4" width="100px;" alt="Royston Shufflebotham"/><br /><sub><b>Royston Shufflebotham</b></sub>](https://github.com/RoystonS)<br />[🐛](https://github.com/kentcdodds/dom-testing-library/issues?q=author%3ARoystonS "Bug reports") [💻](https://github.com/kentcdodds/dom-testing-library/commits?author=RoystonS "Code") [📖](https://github.com/kentcdodds/dom-testing-library/commits?author=RoystonS "Documentation") [⚠️](https://github.com/kentcdodds/dom-testing-library/commits?author=RoystonS "Tests") | [<img src="https://avatars0.githubusercontent.com/u/591673?v=4" width="100px;" alt="Vadim Brodsky"/><br /><sub><b>Vadim Brodsky</b></sub>](http://www.vadimbrodsky.com)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=VadimBrodsky "Code") | [<img src="https://avatars3.githubusercontent.com/u/499898?v=4" width="100px;" alt="Eunjae Lee"/><br /><sub><b>Eunjae Lee</b></sub>](https://twitter.com/eunjae_lee)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=eunjae-lee "Code") | [<img src="https://avatars2.githubusercontent.com/u/167743?v=4" width="100px;" alt="David Peter"/><br /><sub><b>David Peter</b></sub>](http://davidpeter.me)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=sarenji "Code") | [<img src="https://avatars0.githubusercontent.com/u/13174025?v=4" width="100px;" alt="Shy Alter"/><br /><sub><b>Shy Alter</b></sub>](https://twitter.com/@puemos)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=puemos "Code") [📖](https://github.com/kentcdodds/dom-testing-library/commits?author=puemos "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/11966621?v=4" width="100px;" alt="Łukasz Makuch"/><br /><sub><b>Łukasz Makuch</b></sub>](https://lukaszmakuch.pl)<br />[📦](#platform-lukaszmakuch "Packaging/porting to new platform") | [<img src="https://avatars1.githubusercontent.com/u/11150235?v=4" width="100px;" alt="Tyler Haas"/><br /><sub><b>Tyler Haas</b></sub>](https://github.com/tylerthehaas)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=tylerthehaas "Code") [⚠️](https://github.com/kentcdodds/dom-testing-library/commits?author=tylerthehaas "Tests") |
141-
| [<img src="https://avatars2.githubusercontent.com/u/482561?v=4" width="100px;" alt="Vesa Laakso"/><br /><sub><b>Vesa Laakso</b></sub>](http://vesalaakso.com)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=valscion "Code") [⚠️](https://github.com/kentcdodds/dom-testing-library/commits?author=valscion "Tests") |
141+
| [<img src="https://avatars2.githubusercontent.com/u/482561?v=4" width="100px;" alt="Vesa Laakso"/><br /><sub><b>Vesa Laakso</b></sub>](http://vesalaakso.com)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=valscion "Code") [⚠️](https://github.com/kentcdodds/dom-testing-library/commits?author=valscion "Tests") | [<img src="https://avatars0.githubusercontent.com/u/16590492?v=4" width="100px;" alt="Tulsi Sapkota"/><br /><sub><b>Tulsi Sapkota</b></sub>](https://github.com/Tolsee)<br />[💻](https://github.com/kentcdodds/dom-testing-library/commits?author=Tolsee "Code") |
142142

143143
<!-- ALL-CONTRIBUTORS-LIST:END -->
144144

jest.config.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
const baseConfig = require('kcd-scripts/jest')
22

33
module.exports = {
4-
collectCoverageFrom: baseConfig.collectCoverageFrom,
5-
coverageThreshold: baseConfig.coverageThreshold,
6-
projects: [
7-
{
8-
...baseConfig,
9-
displayName: 'jsdom',
10-
testEnvironment: 'jest-environment-jsdom',
11-
},
12-
{
13-
...baseConfig,
14-
displayName: 'node',
15-
testEnvironment: 'jest-environment-node',
16-
},
17-
],
18-
// this is for eslint
19-
modulePaths: baseConfig.modulePaths,
4+
...baseConfig,
5+
testEnvironment: 'jest-environment-jsdom',
206
}

package.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,36 @@
2424
"node": ">=8"
2525
},
2626
"scripts": {
27-
"add-contributor": "kcd-scripts contributors add",
2827
"build": "kcd-scripts build && kcd-scripts build --bundle --no-clean",
2928
"lint": "kcd-scripts lint",
3029
"test": "kcd-scripts test",
3130
"test:update": "npm test -- --updateSnapshot --coverage",
3231
"validate": "kcd-scripts validate",
3332
"setup": "npm install && npm run validate -s",
34-
"precommit": "kcd-scripts precommit",
3533
"dtslint": "dtslint typings"
3634
},
35+
"husky": {
36+
"hooks": {
37+
"pre-commit": "kcd-scripts pre-commit"
38+
}
39+
},
3740
"files": [
3841
"dist",
3942
"typings"
4043
],
4144
"dependencies": {
42-
"@babel/runtime": "^7.1.5",
45+
"@babel/runtime": "^7.3.4",
4346
"@sheerun/mutationobserver-shim": "^0.3.2",
4447
"pretty-format": "^24.0.0",
4548
"wait-for-expect": "^1.1.0"
4649
},
4750
"devDependencies": {
48-
"dtslint": "^0.3.0",
49-
"jest-dom": "^2.1.1",
51+
"dtslint": "^0.5.3",
52+
"jest-dom": "^3.1.2",
5053
"jest-in-case": "^1.0.2",
51-
"jsdom": "^13.0.0",
52-
"kcd-scripts": "^0.46.0"
54+
"jest-watch-select-projects": "^0.1.1",
55+
"jsdom": "^13.2.0",
56+
"kcd-scripts": "^1.1.0"
5357
},
5458
"eslintConfig": {
5559
"extends": "./node_modules/kcd-scripts/eslint.js",

src/__tests__/element-queries.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'jest-dom/extend-expect'
22
import {configure} from '../config'
33
import {render, renderIntoDocument} from './helpers/test-utils'
4-
import document from './helpers/document'
54

65
beforeEach(() => {
76
document.defaultView.Cypress = null

src/__tests__/events.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import {fireEvent} from '..'
2-
import document from './helpers/document'
3-
import window from './helpers/window'
42

53
const eventTypes = [
64
{

src/__tests__/example.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import {getByLabelText, getByText, getByTestId, queryByTestId, wait} from '../'
33
// adds special assertions like toHaveTextContent
44
import 'jest-dom/extend-expect'
5-
import document from './helpers/document'
65

76
function getExampleDOM() {
87
// This is just a raw example of setting up some DOM

src/__tests__/get-queries-for-element.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {getQueriesForElement} from '../get-queries-for-element'
22
import {queries} from '..'
3-
import document from './helpers/document'
43

54
test('uses default queries', () => {
65
const container = document.createElement('div')

0 commit comments

Comments
 (0)