@testing-library/svelte
Advanced tools
Comparing version 2.0.0 to 3.0.0
161
package.json
{ | ||
"name": "@testing-library/svelte", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.", | ||
"main": "dist/index.js", | ||
"types": "types/index.d.ts", | ||
"license": "MIT", | ||
"homepage": "https://github.com/testing-library/svelte-testing-library#readme", | ||
"repository": { | ||
@@ -10,53 +13,121 @@ "type": "git", | ||
}, | ||
"devDependencies": { | ||
"babel-jest": "^24.7.1", | ||
"deasync": "^0.1.14", | ||
"esm": "^3.2.22", | ||
"jest": "^24.7.1", | ||
"jest-dom": "^3.1.2", | ||
"jest-transform-svelte": "^1.0.0", | ||
"kcd-scripts": "^1.4.0", | ||
"npm-run-all": "^4.1.5", | ||
"rollup": "^1.10.1", | ||
"rollup-plugin-commonjs": "^9.3.4", | ||
"rollup-plugin-livereload": "^1.0.0", | ||
"rollup-plugin-node-resolve": "^4.2.3", | ||
"rollup-plugin-svelte": "^5.0.3", | ||
"rollup-plugin-terser": "^4.0.4", | ||
"sirv-cli": "^0.4.0", | ||
"svelte": "^3.0.0" | ||
"bugs": { | ||
"url": "https://github.com/testing-library/svelte-testing-library/issues" | ||
}, | ||
"engines": { | ||
"node": ">= 8" | ||
}, | ||
"keywords": [ | ||
"testing", | ||
"svelte", | ||
"ui", | ||
"dom", | ||
"jsdom", | ||
"unit", | ||
"integration", | ||
"functional", | ||
"end-to-end", | ||
"e2e" | ||
], | ||
"files": [ | ||
"dist", | ||
"dont-cleanup-after-each.js", | ||
"pure.js", | ||
"types/index.d.ts" | ||
], | ||
"scripts": { | ||
"toc": "doctoc README.md", | ||
"lint": "eslint src --fix", | ||
"clean": "rimraf dist", | ||
"build": "npm run clean && babel src --out-dir dist --ignore '**/__tests__/**'", | ||
"test": "jest src", | ||
"test:watch": "npm run test -- --watch", | ||
"test:update": "npm run test -- --updateSnapshot --coverage", | ||
"setup": "npm install && npm run validate", | ||
"validate": "npm run clean && npm-run-all lint test build", | ||
"contributors:add": "all-contributors add", | ||
"contributors:generate": "all-contributors generate" | ||
}, | ||
"peerDependencies": { | ||
"svelte": "3.x" | ||
}, | ||
"scripts": { | ||
"lint": "kcd-scripts lint", | ||
"validate": "kcd-scripts validate", | ||
"build": "kcd-scripts build", | ||
"build:example": "rollup -c", | ||
"autobuild:example": "rollup -c -w", | ||
"dev": "run-p start:dev autobuild", | ||
"start": "sirv public", | ||
"start:dev": "sirv public --dev", | ||
"test": "kcd-scripts test --no-watch --config=jest.config.js" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.4.3", | ||
"@testing-library/dom": "^5.0.1", | ||
"core-js": "^3.0.1" | ||
"@testing-library/dom": "^7.0.3" | ||
}, | ||
"eslintConfig": { | ||
"extends": "./node_modules/kcd-scripts/eslint.js", | ||
"rules": { | ||
"react/prop-types": "off", | ||
"import/no-unassigned-import": "off", | ||
"import/named": "off" | ||
"devDependencies": { | ||
"@babel/cli": "^7.6.2", | ||
"@babel/core": "^7.6.2", | ||
"@babel/plugin-transform-modules-commonjs": "^7.6.0", | ||
"@babel/preset-env": "^7.6.2", | ||
"@commitlint/cli": "^8.2.0", | ||
"@commitlint/config-conventional": "^8.2.0", | ||
"@testing-library/jest-dom": "^5.0.2", | ||
"@types/jest": "^25.1.0", | ||
"all-contributors-cli": "^6.9.0", | ||
"babel-eslint": "^10.0.3", | ||
"babel-jest": "^25.1.0", | ||
"doctoc": "^1.4.0", | ||
"eslint": "^6.2.2", | ||
"eslint-config-standard": "^14.1.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-node": "^11.0.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-simple-import-sort": "^5.0.0", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"eslint-plugin-svelte3": "^2.7.3", | ||
"husky": "^4.0.9", | ||
"jest": "^25.1.0", | ||
"lint-staged": "^10.0.0", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^1.18.2", | ||
"svelte": "^3.0.0", | ||
"svelte-jester": "^1.0.3" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged", | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
} | ||
}, | ||
"eslintIgnore": [ | ||
"node_modules", | ||
"coverage", | ||
"dist", | ||
"public" | ||
] | ||
} | ||
"lint-staged": { | ||
"README.md": [ | ||
"yarn toc", | ||
"prettier --parser markdown --write", | ||
"git add" | ||
], | ||
".all-contributorsrc": [ | ||
"yarn contributors:generate", | ||
"git add" | ||
], | ||
"**/*.js": [ | ||
"yarn lint", | ||
"yarn test", | ||
"git add" | ||
] | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"jest": { | ||
"testPathIgnorePatterns": [ | ||
"src/__tests__/fixtures" | ||
], | ||
"collectCoverageFrom": [ | ||
"src/*.js" | ||
], | ||
"setupFilesAfterEnv": [ | ||
"@testing-library/jest-dom/extend-expect" | ||
], | ||
"transform": { | ||
"^.+\\.js$": "babel-jest", | ||
"^.+\\.svelte$": "svelte-jester", | ||
"^.+\\.html$": "svelte-jester" | ||
}, | ||
"moduleFileExtensions": [ | ||
"js", | ||
"svelte" | ||
] | ||
} | ||
} |
181
README.md
<div align="center"> | ||
<h1>svelte-testing-library</h1> | ||
<h1>Svelte Testing Library</h1> | ||
@@ -16,12 +16,5 @@ <a href="https://www.emojione.com/emoji/1f410"> | ||
<br /> | ||
[**Read The Docs**](https://testing-library.com/svelte) | | ||
[**Read The Docs**](https://testing-library.com/docs/svelte-testing-library/intro) | | ||
[Edit the docs](https://github.com/alexkrolick/testing-library-docs) | ||
<br /> | ||
</div> | ||
<hr /> | ||
<!-- prettier-ignore-start --> | ||
@@ -33,3 +26,3 @@ [![Build Status][build-badge]][build] | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors) | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-) | ||
[![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] | ||
@@ -41,15 +34,7 @@ [![Join the community on Spectrum][spectrum-badge]][spectrum] | ||
[![Tweet][twitter-badge]][twitter] | ||
<!-- prettier-ignore-end --> | ||
<div align="center"> | ||
<a href="https://testingjavascript.com"> | ||
<img | ||
width="500" | ||
alt="TestingJavaScript.com Learn the smart, efficient way to test any JavaScript application." | ||
src="https://raw.githubusercontent.com/testing-library/react-testing-library/master/other/testingjavascript.jpg" | ||
/> | ||
</a> | ||
</div> | ||
<hr /> | ||
## Table of Contents | ||
@@ -60,10 +45,6 @@ | ||
- [The problem](#the-problem) | ||
- [This solution](#this-solution) | ||
- [Example](#example) | ||
- [The Problem](#the-problem) | ||
- [This Solution](#this-solution) | ||
- [Installation](#installation) | ||
- [Examples](#examples) | ||
- [Other Solutions](#other-solutions) | ||
- [Guiding Principles](#guiding-principles) | ||
- [Contributors](#contributors) | ||
- [Docs](#docs) | ||
@@ -74,2 +55,3 @@ - [Issues](#issues) | ||
- [❓ Questions](#-questions) | ||
- [Contributors](#contributors) | ||
- [LICENSE](#license) | ||
@@ -79,13 +61,8 @@ | ||
## The problem | ||
## The Problem | ||
You want to write maintainable tests for your Svelte components. As a part of | ||
this goal, you want your tests to avoid including implementation details of your | ||
components and rather focus on making your tests give you the confidence for | ||
which they are intended. As part of this, you want your testbase to be | ||
maintainable in the long run so refactors of your components (changes to | ||
implementation but not functionality) don't break your tests and slow you and | ||
your team down. | ||
You want to write tests for your Svelte components so that they avoid including implementation | ||
details, and are maintainable in the long run. | ||
## This solution | ||
## This Solution | ||
@@ -100,44 +77,2 @@ The `svelte-testing-library` is a very lightweight solution for testing Svelte | ||
## Example | ||
App.svelte | ||
```html | ||
<script> | ||
export let name | ||
</script> | ||
<style> | ||
h1 { | ||
color: purple; | ||
} | ||
</style> | ||
<h1>Hello {name}!</h1> | ||
``` | ||
App.spec.js | ||
```javascript | ||
import App from '../src/App.svelte' | ||
import {render} from '@testing-library/svelte' | ||
describe('App', () => { | ||
test('should render greeting', () => { | ||
const {getByText} = render(App, {props: {name: 'world'}}) | ||
expect(getByText('Hello world!')) | ||
}) | ||
test('should change button text after click', async () => { | ||
const {getByText} = render(App, {props: {name: 'world'}}) | ||
fireEvent.click(getByText('Button Text')) | ||
const button = await waitForElement(() => getByText('Button Clicked')) | ||
expect(button).toBeInTheDocument() | ||
}) | ||
}) | ||
``` | ||
## Installation | ||
@@ -149,55 +84,13 @@ | ||
``` | ||
npm install --save-dev svelte-testing-library | ||
npm install --save-dev @testing-library/svelte | ||
``` | ||
This library has `peerDependencies` listings for `svelte`. | ||
This library has `peerDependencies` listings for `svelte >= 3`. | ||
You may also be interested in installing `jest-dom` so you can use | ||
[the custom jest matchers](https://github.com/gnapse/jest-dom#readme). | ||
You may also be interested in installing `@testing-library/jest-dom` so you can use | ||
[the custom jest matchers](https://github.com/testing-library/jest-dom). | ||
> [**Docs**](https://testing-library.com/docs/svelte-testing-library/intro) | ||
## Guiding Principles | ||
> [The more your tests resemble the way your software is used, the more | ||
> confidence they can give you.][guiding-principle] | ||
We try to only expose methods and utilities that encourage you to write tests | ||
that closely resemble how your svelte components are used. | ||
Utilities are included in this project based on the following guiding | ||
principles: | ||
1. If it relates to rendering components, it deals with DOM nodes rather than | ||
component instances, nor should it encourage dealing with component | ||
instances. | ||
2. It should be generally useful for testing individual Svelte components or | ||
full Svelte applications. | ||
3. Utility implementations and APIs should be simple and flexible. | ||
At the end of the day, what we want is for this library to be pretty | ||
light-weight, simple, and understandable. | ||
## Contributors | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
<!-- prettier-ignore --> | ||
<table><tr><td align="center"><a href="https://github.com/benmonro"><img src="https://avatars3.githubusercontent.com/u/399236?v=4" width="100px;" alt="Ben Monro"/><br /><sub><b>Ben Monro</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Tests">⚠️</a> <a href="#ideas-benmonro" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Documentation">📖</a></td><td align="center"><a href="https://twitter.com/EmilTholin"><img src="https://avatars0.githubusercontent.com/u/11573167?v=4" width="100px;" alt="Emil Tholin"/><br /><sub><b>Emil Tholin</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=EmilTholin" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=EmilTholin" title="Tests">⚠️</a> <a href="#ideas-EmilTholin" title="Ideas, Planning, & Feedback">🤔</a></td><td align="center"><a href="https://medium.com/@oieduardorabelo"><img src="https://avatars1.githubusercontent.com/u/829902?v=4" width="100px;" alt="Eduardo Rabelo"/><br /><sub><b>Eduardo Rabelo</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Tests">⚠️</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Code">💻</a></td><td align="center"><a href="http://timdeschryver.dev"><img src="https://avatars1.githubusercontent.com/u/28659384?v=4" width="100px;" alt="Tim Deschryver"/><br /><sub><b>Tim Deschryver</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=timdeschryver" title="Documentation">📖</a></td><td align="center"><a href="http://www.ematipico.com"><img src="https://avatars3.githubusercontent.com/u/602478?v=4" width="100px;" alt="Emanuele"/><br /><sub><b>Emanuele</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Tests">⚠️</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Documentation">📖</a></td></tr></table> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
Thanks goes to these people ([emoji key][emojis]): | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
<!-- prettier-ignore --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
This project follows the [all-contributors][all-contributors] specification. | ||
Contributions of any kind welcome! | ||
## Docs | ||
[**Read The Docs**](https://testing-library.com/docs/svelte-testing-library/intro) | | ||
[Edit the docs](https://github.com/alexkrolick/testing-library-docs) | ||
See the [**docs**](https://testing-library.com/docs/svelte-testing-library/intro) over at the Testing Library website. | ||
@@ -230,10 +123,35 @@ ## Issues | ||
## Contributors | ||
Thanks goes to these people ([emoji key][emojis]): | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
<!-- prettier-ignore-start --> | ||
<!-- markdownlint-disable --> | ||
<table> | ||
<tr> | ||
<td align="center"><a href="https://github.com/benmonro"><img src="https://avatars3.githubusercontent.com/u/399236?v=4" width="100px;" alt="Ben Monro"/><br /><sub><b>Ben Monro</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Tests">⚠️</a> <a href="#ideas-benmonro" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Documentation">📖</a></td> | ||
<td align="center"><a href="https://twitter.com/EmilTholin"><img src="https://avatars0.githubusercontent.com/u/11573167?v=4" width="100px;" alt="Emil Tholin"/><br /><sub><b>Emil Tholin</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=EmilTholin" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=EmilTholin" title="Tests">⚠️</a> <a href="#ideas-EmilTholin" title="Ideas, Planning, & Feedback">🤔</a></td> | ||
<td align="center"><a href="https://medium.com/@oieduardorabelo"><img src="https://avatars1.githubusercontent.com/u/829902?v=4" width="100px;" alt="Eduardo Rabelo"/><br /><sub><b>Eduardo Rabelo</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Tests">⚠️</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Documentation">📖</a> <a href="#example-oieduardorabelo" title="Examples">💡</a></td> | ||
<td align="center"><a href="http://timdeschryver.dev"><img src="https://avatars1.githubusercontent.com/u/28659384?v=4" width="100px;" alt="Tim Deschryver"/><br /><sub><b>Tim Deschryver</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=timdeschryver" title="Documentation">📖</a></td> | ||
<td align="center"><a href="http://www.ematipico.com"><img src="https://avatars3.githubusercontent.com/u/602478?v=4" width="100px;" alt="Emanuele"/><br /><sub><b>Emanuele</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Tests">⚠️</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Documentation">📖</a></td> | ||
<td align="center"><a href="https://github.com/pngwn"><img src="https://avatars1.githubusercontent.com/u/12937446?v=4" width="100px;" alt="pngwn"/><br /><sub><b>pngwn</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=pngwn" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=pngwn" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://twitter.com/sebsilbermann"><img src="https://avatars3.githubusercontent.com/u/12292047?v=4" width="100px;" alt="Sebastian Silbermann"/><br /><sub><b>Sebastian Silbermann</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=eps1lon" title="Code">💻</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="https://github.com/mihar-22"><img src="https://avatars3.githubusercontent.com/u/14304599?s=460&v=4" width="100px;" alt="Rahim Alwer"/><br /><sub><b>Rahim Alwer</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=mihar-22" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=mihar-22" title="Documentation">📖</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=mihar-22" title="Tests">⚠️</a></td> | ||
</tr> | ||
</table> | ||
<!-- markdownlint-enable --> | ||
<!-- prettier-ignore-end --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
This project follows the [all-contributors][all-contributors] specification. | ||
Contributions of any kind welcome! | ||
## LICENSE | ||
MIT | ||
[MIT](LICENSE) | ||
<!-- | ||
Links: | ||
--> | ||
<!-- prettier-ignore-start --> | ||
@@ -253,3 +171,3 @@ | ||
[spectrum]: https://spectrum.chat/testing-library | ||
[license-badge]: https://img.shields.io/npm/l/svelte-testing-library.svg?style=flat-square | ||
[license-badge]: https://img.shields.io/github/license/testing-library/svelte-testing-library?color=b | ||
[license]: https://github.com/testing-library/svelte-testing-library/blob/master/LICENSE | ||
@@ -277,1 +195,2 @@ [prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square | ||
<!-- prettier-ignore-end --> | ||
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
2
207
1
0
24591
27
8
186
1
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/runtime-corejs3@7.26.0(transitive)
+ Added@jest/types@26.6.2(transitive)
+ Added@testing-library/dom@7.31.2(transitive)
+ Added@types/aria-query@4.2.2(transitive)
+ Added@types/istanbul-reports@3.0.4(transitive)
+ Added@types/node@22.10.7(transitive)
+ Added@types/yargs@15.0.19(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedaria-query@4.2.2(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcore-js-pure@3.40.0(transitive)
+ Addeddom-accessibility-api@0.5.16(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedlz-string@1.5.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpretty-format@26.6.2(transitive)
+ Addedreact-is@17.0.2(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removed@babel/runtime@^7.4.3
- Removedcore-js@^3.0.1
- Removed@jest/types@24.9.0(transitive)
- Removed@sheerun/mutationobserver-shim@0.3.3(transitive)
- Removed@testing-library/dom@5.6.1(transitive)
- Removed@types/istanbul-reports@1.1.2(transitive)
- Removed@types/yargs@13.0.12(transitive)
- Removedansi-regex@4.1.1(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedaria-query@3.0.0(transitive)
- Removedast-types-flow@0.0.7(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcore-js@3.40.0(transitive)
- Removedpretty-format@24.9.0(transitive)
- Removedreact-is@16.13.1(transitive)
- Removedwait-for-expect@1.3.0(transitive)
Updated@testing-library/dom@^7.0.3