Skip to content

Commit e86c0c6

Browse files
[docs] Add WebdriverIO as alternative testing solution
1 parent 1852bc4 commit e86c0c6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

site/content/faq/800-how-do-i-test-svelte-apps.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ question: How do I test Svelte apps?
44

55
We recommend trying to separate your view logic from your business logic. Data transformation or cross component state management is best kept outside of Svelte components. You can test those parts like you would test any JavaScript functionality that way. When it comes to testing the components, it is best to test the logic of the component and remember that the Svelte library has its own tests and you do not need to test implementation details provided by Svelte.
66

7-
There are a few approaches that people take when testing, but it generally involves compiling the component and mounting it to something and then performing the tests. You essentially need to create a bundle for each component you're testing (since svelte is a compiler and not a normal library) and then mount them. You can mount to a JSDOM instance. Or you can use a real browser powered by a library like Playwright, Puppeteer, or Cypress.
7+
There are a few approaches that people take when testing, but it generally involves compiling the component and mounting it to something and then performing the tests. You essentially need to create a bundle for each component you're testing (since svelte is a compiler and not a normal library) and then mount them. You can mount to a JSDOM instance. Or you can use a real browser powered by a library like Playwright, Puppeteer, WebdriverIO or Cypress.
88

99
Some resources for getting started with unit testing:
1010
- [Svelte Testing Library](https://testing-library.com/docs/svelte-testing-library/example/)
1111
- [Example using vitest](https://github.com/vitest-dev/vitest/tree/main/examples/svelte)
1212
- [Example using uvu test runner with JSDOM](https://github.com/lukeed/uvu/tree/master/examples/svelte)
13+
- [Component testing in real browser](https://webdriver.io/docs/component-testing/svelte)

0 commit comments

Comments
 (0)