KEMBAR78
Build reliable Svelte applications using Cypress | PPTX
Build reliableSvelte
applications usingCypress
Maurice de Beijer
@mauricedb
1
 Maurice de Beijer
 The Problem Solver
 Microsoft MVP
 Freelance developer/instructor
 Twitter: @mauricedb
 Web: http://www.TheProblemSolver.nl
 E-mail: maurice.de.beijer@gmail.com
2
Cypress.io
Course
3
Topics
 What is Cypress.io?
 UsingTDD to building a SvelteKit application
 Testing pages
 API testing
 Running the Cypress tests in GitHub Actions
4
What isCypress and
why should you care?
5
Cypress.io
6
What is
Cypress?
 Cypress is a front end testing tool
 Built for the modern web
 Tests are easy to write
 Using simple JavaScript orTypeScript
 TimeTravel runner lets you inspect test at each step
 Click on a step to see the state of the browser
 Automatic waiting for elements
 Makes tests more resilient
 Video recording of running test
 Helps debugging failing tests on the CI server
7
What is
Cypress?
 Lets you fake the network when required
 Or use the real backend as appropriate
 Automatically retry of failing tests
 Run flaky tests multiple times
 Many standard and 3rd party extensions
 Or write your own in JavaScript
 Can run in Docker containers
 Consistent cross platform behavior
 Runs inside the browser
 Not based onW3C WebDriver API
8
Testing
Triangle
🗣
End 2 End
Integration
UnitTesting
9
UnitTesting
10
Why End to End?
The more your tests resemble the way your software
is used, the more confidence they can give you!
Kent C. Dodds
11
What we are
building
12
How we are
testing
13
What is already done?
14
npm init svelte
15
Dependencies
16
Header.svelte
17
MovieCard.svelte
18
Cypress andTDD
19
Testing the
navigation
20
Testing anAPI
21
Intercepting an
AJAX request
22
GitHubAction
23
Code/Slides
 http://theproblemsolver.nl/Presentations
 https://github.com/mauricedb/sveltekit-cypress-tdd
24
Conclusion
 Cypress is a great tool for End to End testing
 More reliable then relying on unit testing and manual testing
 Write tests that resemble your user’s actions
 Great approach forTest Driven Development
 Test that your API’s return the shape you expect
 A mismatch can lead to vague errors
25
Maurice de Beijer
@mauricedb
maurice.de.beijer
@gmail.com
26

Build reliable Svelte applications using Cypress