Fireship · @fireship
Cypress in 100 Seconds
Uploaded March 29, 2022 · Length 2:31
Summary
Cypress is a testing solution for web applications that makes test-driven development fun for JavaScript developers.
- cypress testing
- javascript testing
- web application testing
- test driven development
- end to end testing
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
Cyprus a testing solution for web
- 0:02
applications famous for making test
- 0:04
driven development fun for JavaScript
- 0:06
developers we all know testing is the
- 0:08
right thing to do but actually doing it
- 0:10
in a front-end JavaScript project can be
- 0:12
complicated slow and just not fun for
- 0:14
many the obvious solution is to simply
- 0:16
not test anything at all that's not
- 0:18
ideal Cypress provides an open source
- 0:20
browser-based test Runner that can
- 0:22
experience your website just like the
- 0:24
end user would it might fill out a login
- 0:25
form click the submit button then
- 0:27
navigate to the user dashboard all of
- 0:29
which happens programmatically based on
- 0:31
code you define every test is recorded
- 0:33
and a snapshot is saved at each step
- 0:35
this makes it possible to time travel
- 0:37
through the user experience to figure
- 0:38
out precisely why your code sucks and
- 0:41
unlike traditional testing utilities
- 0:42
debugging can be performed directly from
- 0:44
the browser Dev tools not only does it
- 0:46
work for end to-end testing of an entire
- 0:48
application but it's also great for
- 0:50
integration testing and unit testing of
- 0:53
isolated components or JavaScript
- 0:54
business logic to get started install it
- 0:57
into your project then run npx Cypress
- 0:59
own open notice how this pulls up the
- 1:01
test Runner automatically and creates a
- 1:03
folder in the root of your project named
- 1:05
Cyprus that contains all of your testing
- 1:07
code fixtures is where you would Define
- 1:08
mock data plugins allow you to hook into
- 1:11
the testing life cycle support is for
- 1:13
your Global configuration then your main
- 1:15
testing code lives in the integration
- 1:17
file we can create a test Suite with
- 1:19
describe then before each test we can
- 1:21
run some setup code like tell Cypress to
- 1:23
visit a specific URL from there use it
- 1:26
to describe a test case where you might
- 1:28
verify that the web page contains a a
- 1:30
certain piece of content the git method
- 1:31
will grab an element from the Dom and
- 1:33
allow you to run assertions on it like
- 1:35
it should have the text login it bundles
- 1:37
the chai assertion library for
- 1:39
behavior-driven development which will
- 1:41
autocomplete with intellisense from
- 1:42
there you may want to find a form input
- 1:45
and type something into it after the
- 1:46
form is filled out submit it to update
- 1:48
your database the great thing about
- 1:50
Cypress is that it will automatically
- 1:51
wait for async events which means you
- 1:53
don't need to add a bunch of sleepers in
- 1:55
your test code things just work
- 1:56
naturally now run your test to watch
- 1:58
everything go down visually a snapshot


