├── .all-contributorsrc ├── .babelrc ├── .babelrc.esm.json ├── .editorconfig ├── .eslintrc.js ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── validate.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── .prettierrc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── add-extensions.js ├── dont-clean-up-after-each.js ├── other └── poodle.png ├── package.json ├── pure.d.ts ├── pure.js ├── src ├── __mocks__ │ └── axios.js ├── __tests__ │ ├── __snapshots__ │ │ └── render.js.snap │ ├── act.js │ ├── auto-cleanup-skip.js │ ├── auto-cleanup.js │ ├── cleanup.js │ ├── debug.js │ ├── end-to-end.js │ ├── events-compat.js │ ├── events.js │ ├── multi-base.js │ ├── render.js │ ├── renderHook.js │ ├── rerender.js │ └── stopwatch.js ├── fire-event.js ├── index.js └── pure.js └── types ├── index.d.ts └── pure.d.ts /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "preact-testing-library", 3 | "projectOwner": "testing-library", 4 | "repoType": "github", 5 | "files": [ 6 | "README.md" 7 | ], 8 | "imageSize": 100, 9 | "commit": false, 10 | "contributors": [ 11 | { 12 | "login": "kentcdodds", 13 | "name": "Kent C. Dodds", 14 | "avatar_url": "https://avatars.githubusercontent.com/u/1500684?v=3", 15 | "profile": "https://kentcdodds.com", 16 | "contributions": [ 17 | "code", 18 | "doc", 19 | "test" 20 | ] 21 | }, 22 | { 23 | "login": "antsmartian", 24 | "name": "Ants Martian", 25 | "avatar_url": "https://avatars0.githubusercontent.com/u/1241511?s=400&v=4", 26 | "profile": "https://github.com/antsmartian", 27 | "contributions": [ 28 | "code", 29 | "doc", 30 | "test" 31 | ] 32 | }, 33 | { 34 | "login": "mihar-22", 35 | "name": "Rahim Alwer", 36 | "avatar_url": "https://avatars3.githubusercontent.com/u/14304599?s=460&v=4", 37 | "profile": "https://github.com/mihar-22", 38 | "contributions": [ 39 | "code", 40 | "doc", 41 | "test", 42 | "infra" 43 | ] 44 | } 45 | ], 46 | "contributorsPerLine": 7, 47 | "repoHost": "https://github.com", 48 | "commitConvention": "none" 49 | } 50 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["@babel/preset-env", { "targets": { "node": "12" } }]], 4 | "plugins": [ 5 | ["@babel/plugin-proposal-class-properties"], 6 | ["@babel/plugin-transform-react-jsx", { "pragma": "h" }], 7 | ["@babel/plugin-transform-modules-commonjs", {"allowTopLevelThis": true}] 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.babelrc.esm.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "modules": false, 7 | "targets": { "node": "12" } 8 | } 9 | ] 10 | ], 11 | "plugins": [ 12 | ["@babel/plugin-proposal-class-properties"], 13 | ["@babel/plugin-transform-react-jsx", { "pragma": "h" }], 14 | ["./add-extensions", { "extension": "mjs" }] 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | 10 | [*.md] 11 | max_line_length = off 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | browser: true, 5 | es6: true, 6 | jest: true 7 | }, 8 | parser: 'babel-eslint', 9 | extends: [ 10 | "standard" 11 | ], 12 | plugins: [ 13 | 'simple-import-sort', 14 | 'react-hooks' 15 | ], 16 | rules: { 17 | 'max-len': ['warn', {'code': 100}], 18 | 'react-hooks/rules-of-hooks': 'error', 19 | 'react-hooks/exhaustive-deps': 'warn', 20 | 'no-unused-vars': 'off' 21 | } 22 | }; 23 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.js text eol=lf 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 43 | 44 | - `preact-testing-library` version: 45 | - `preact` version: 46 | - `node` version: 47 | - `npm` (or `yarn`) version: 48 | 49 | **Relevant code or config** 50 | 51 | **What you did:** 52 | 53 | **What happened:** 54 | 55 | 56 | 57 | Reproduction repository: 58 | 59 | 66 | 67 | Problem description: 68 | 69 | 70 | 71 | Suggested solution: 72 | 73 | 77 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | **What**: 20 | 21 | 22 | 23 | **Why**: 24 | 25 | 26 | 27 | **How**: 28 | 29 | 30 | 31 | **Checklist**: 32 | 33 | 34 | 35 | 36 | 37 | - [ ] Documentation added 38 | - [ ] Tests 39 | - [ ] Typescript definitions updated 40 | - [ ] Ready to be merged 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /.github/workflows/validate.yml: -------------------------------------------------------------------------------- 1 | name: validate 2 | on: 3 | push: 4 | branches: 5 | - '+([0-9])?(.{+([0-9]),x}).x' 6 | - 'main' 7 | - 'next' 8 | - 'next-major' 9 | - 'beta' 10 | - 'alpha' 11 | - '!all-contributors/**' 12 | pull_request: 13 | 14 | concurrency: 15 | group: ${{ github.workflow }}-${{ github.ref }} 16 | cancel-in-progress: true 17 | 18 | jobs: 19 | main: 20 | # ignore all-contributors PRs 21 | if: ${{ !contains(github.head_ref, 'all-contributors') }} 22 | strategy: 23 | matrix: 24 | node: [16, 18, 20] 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: ⬇️ Checkout repo 28 | uses: actions/checkout@v2 29 | 30 | - name: ⎔ Setup node 31 | uses: actions/setup-node@v2 32 | with: 33 | node-version: ${{ matrix.node }} 34 | 35 | - name: 📥 Download deps 36 | uses: bahmutov/npm-install@v1 37 | with: 38 | useLockFile: false 39 | env: 40 | HUSKY_SKIP_INSTALL: true 41 | 42 | - name: ▶️ Run validate script 43 | run: npm run validate 44 | 45 | - name: ⬆️ Upload coverage report 46 | uses: codecov/codecov-action@v2 47 | 48 | release: 49 | needs: main 50 | runs-on: ubuntu-latest 51 | if: 52 | ${{ github.repository == 'testing-library/preact-testing-library' && 53 | contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha', github.ref) && 54 | github.event_name == 'push' }} 55 | steps: 56 | - name: ⬇️ Checkout repo 57 | uses: actions/checkout@v2 58 | 59 | - name: ⎔ Setup node 60 | uses: actions/setup-node@v2 61 | with: 62 | node-version: 14 63 | 64 | - name: 📥 Download deps 65 | uses: bahmutov/npm-install@v1 66 | with: 67 | useLockFile: false 68 | env: 69 | HUSKY_SKIP_INSTALL: true 70 | 71 | - name: 🏗 Run build script 72 | run: npm run build 73 | 74 | - name: 🚀 Release 75 | uses: cycjimmy/semantic-release-action@v2 76 | with: 77 | semantic_version: 17 78 | branches: | 79 | [ 80 | '+([0-9])?(.{+([0-9]),x}).x', 81 | 'main', 82 | 'next', 83 | 'next-major', 84 | {name: 'beta', prerelease: true}, 85 | {name: 'alpha', prerelease: true} 86 | ] 87 | env: 88 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 89 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 90 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | dist 4 | .opt-in 5 | .opt-out 6 | .DS_Store 7 | .eslintcache 8 | .idea 9 | 10 | yarn-error.log 11 | package-lock.json 12 | yarn.lock 13 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | package-lock=false 3 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json 2 | node_modules 3 | dist 4 | coverage 5 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": false, 6 | "singleQuote": true, 7 | "trailingComma": "all", 8 | "bracketSpacing": true, 9 | "jsxBracketSameLine": false, 10 | "proseWrap": "always" 11 | } 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | The changelog is automatically updated using 4 | [semantic-release](https://github.com/semantic-release/semantic-release). You 5 | can see it on the [releases page](../../releases). 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of 9 | experience, nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | - Using welcoming and inclusive language 18 | - Being respectful of differing viewpoints and experiences 19 | - Gracefully accepting constructive criticism 20 | - Focusing on what is best for the community 21 | - Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | - The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | - Trolling, insulting/derogatory comments, and personal or political attacks 28 | - Public or private harassment 29 | - Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | - Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or reject 41 | comments, commits, code, wiki edits, issues, and other contributions that are 42 | not aligned to this Code of Conduct, or to ban temporarily or permanently any 43 | contributor for other behaviors that they deem inappropriate, threatening, 44 | offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an 62 | incident. Further details of specific enforcement policies may be posted 63 | separately. 64 | 65 | Project maintainers who do not follow or enforce the Code of Conduct in good 66 | faith may face temporary or permanent repercussions as determined by other 67 | members of the project's leadership. 68 | 69 | ## Attribution 70 | 71 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 72 | version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 73 | 74 | [homepage]: http://contributor-covenant.org 75 | [version]: http://contributor-covenant.org/version/1/4/ 76 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thanks for being willing to contribute! 4 | 5 | **Working on your first Pull Request?** You can learn how from this _free_ series [How to Contribute 6 | to an Open Source Project on GitHub][egghead] 7 | 8 | ## Project setup 9 | 10 | 1. Fork and clone the repo 11 | 2. Run `npm run setup -s` to install dependencies and run validation 12 | 3. Create a branch for your PR with `git checkout -b pr/your-branch-name` 13 | 14 | > Tip: Keep your `main` branch pointing at the original repository and make pull requests from 15 | > branches on your fork. To do this, run: 16 | > 17 | > ``` 18 | > git remote add upstream https://github.com/testing-library/preact-testing-library.git 19 | > git fetch upstream 20 | > git branch --set-upstream-to=upstream/main main 21 | > ``` 22 | > 23 | > This will add the original repository as a "remote" called "upstream," Then fetch the git 24 | > information from that remote, then set your local `main` branch to use the upstream main branch 25 | > whenever you run `git pull`. Then you can make all of your pull request branches based on this 26 | > `main` branch. Whenever you want to update your version of `main`, do a regular `git pull`. 27 | 28 | ## Committing and Pushing changes 29 | 30 | Please make sure to run the tests before you commit your changes. You can run `npm run test:update` 31 | which will update any snapshots that need updating. Make sure to include those changes (if they 32 | exist) in your commit. 33 | 34 | ## Help needed 35 | 36 | Please checkout the [the open issues][issues] 37 | 38 | Also, please watch the repo and respond to questions/bug reports/feature requests! Thanks! 39 | 40 | [egghead]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github 41 | [issues]: https://github.com/testing-library/preact-testing-library/issues 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Rahim Alwer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
Simple and complete Preact DOM testing utilities that encourage good testing 14 | practices.
15 | 16 | > Inspired completely by [react-testing-library][react-testing-library] 17 | 18 | [![Build Status][build-badge]][build] [![Code Coverage][coverage-badge]][coverage] 19 | [](#contributors-) 20 | [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] 21 | [![version][version-badge]][package] [![downloads][downloads-badge]][package] 22 | [![MIT License][license-badge]][license] 23 | [![Preact Slack Community][preact-slack-badge]][preact-slack] 24 | [![Commitzen][commitzen-badge]][commitzen] [![Discord][discord-badge]][discord] 25 | 26 |Kent C. Dodds 💻 📖 ⚠️ |
120 | Ants Martian 💻 📖 ⚠️ |
121 | Rahim Alwer 💻 📖 ⚠️ 🚇 |
122 |
7 | DocumentFragment
8 |
9 | is pretty cool!
10 |