Skip to content

Commit 3582c10

Browse files
benmonroalexkrolick
authored andcommitted
add Svelte docs & a known issue in testcafe. (#104)
* Create intro.md * doc: added testcafe-testing-library docs * doc: cleaned up some little details * added note for container * add docs for within * added svelte & known issue w/ testcafe * added note about jest-transform-svelte * removed old example * added logos to home page
1 parent 0b3e981 commit 3582c10

File tree

6 files changed

+92
-0
lines changed

6 files changed

+92
-0
lines changed

docs/svelte-testing-library/intro.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
id: intro
3+
title: Svelte Testing Library
4+
---
5+
6+
[`svelte-testing-library`][gh] simplifies the use of dom-testing with
7+
[Svelte](https://svelte.dev/) components & applications.
8+
9+
```
10+
npm install --save-dev svlt-testing-library
11+
```
12+
13+
- [svelte-testing-library on GitHub][gh]
14+
15+
## Usage
16+
17+
You will first need to install and configure
18+
[jest-transform-svelte](https://www.npmjs.com/package/jest-transform-svelte) in
19+
order to use svelte in jest.
20+
21+
You must add `cleanup` to your test fixture's `beforeEach` hook:
22+
23+
```javascript
24+
import { render, cleanup } from 'svlt-testing-library'
25+
26+
beforeEach(cleanup) //this is required.
27+
```
28+
29+
## Examples
30+
31+
App.svelte
32+
33+
```html
34+
<script>
35+
export let name
36+
</script>
37+
38+
<style>
39+
h1 {
40+
color: purple;
41+
}
42+
</style>
43+
44+
<h1>Hello {name}!</h1>
45+
```
46+
47+
App.spec.js
48+
49+
```javascript
50+
import App from '../src/App.svelte'
51+
import { render, cleanup } from 'svlt-testing-library'
52+
beforeEach(cleanup)
53+
describe('App', () => {
54+
test('should render greeting', () => {
55+
const { getByText } = render(App, { props: { name: 'world' } })
56+
57+
expect(getByText('Hello world!'))
58+
})
59+
60+
test('should change button text after click', async () => {
61+
const { getByText } = render(App, { props: { name: 'world' } })
62+
63+
fireEvent.click(getByText('Button Text'))
64+
65+
const button = await waitForElement(() => getByText('Button Clicked'))
66+
67+
expect(button).toBeInTheDocument()
68+
})
69+
})
70+
```
71+
72+
[gh]: https://github.com/testing-library/svelte-testing-library

docs/testcafe-testing-library/intro.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,12 @@ test("queryByPlaceholder doesn't find anything", async t => {
8686
})
8787
```
8888

89+
## Known Issues
90+
91+
Whenever a non-client side browser navigation event occurs, you will need to
92+
make another call to `addTestcafeTestingLibrary`. Testcafe uses a Proxy to
93+
inject & execute tests/selectors. AFAIK, there's no way to tap into an
94+
`on("navigate")` event. I have filed an issue with Testcafe to address this so
95+
feel free to give it a +1. https://github.com/DevExpress/testcafe/issues/3758
96+
8997
[gh]: https://github.com/benmonro/testcafe-testing-library

website/pages/en/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ class Index extends React.Component {
195195
title:
196196
'[Cypress Testing Library](./docs/cypress-testing-library/intro)',
197197
},
198+
{
199+
image: `${baseUrl}img/testcafe-128x128.jpg`,
200+
imageAlign: 'top',
201+
title: `[Testcafe Testing Library](./docs/testcafe-testing-library/intro)`,
202+
},
203+
{
204+
image: `${baseUrl}img/svelte-128x128.png`,
205+
imageAlign: 'top',
206+
title:
207+
'[Svelte Testing Library](./docs/svelte-testing-library/intro)',
208+
},
198209
{
199210
image: `${baseUrl}img/vue-400x400.png`,
200211
imageAlign: 'top',

website/sidebars.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
]
5252
},
5353
"cypress-testing-library/intro",
54+
"svelte-testing-library/intro",
5455
"vue-testing-library/intro",
5556
"angular-testing-library/intro",
5657
"pptr-testing-library/intro",

website/static/img/svelte-128x128.png

16.7 KB
Loading
3.79 KB
Loading

0 commit comments

Comments
 (0)