E2E Tests for Signup Component
Let's add Cypress tests for our signup component.
We'll cover the following...
Our signup test is set up, ready, and running. It’s time to add E2E tests for our signup component. Below is our updated code:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>LetsGetLunch</title> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> </head> <body> <app-root></app-root> </body> </html>
Signup test setup
Signup test
-
Utilize an
it
, passing it the title of our test, followed by a function containing the test itself. -
Begin the test with
cy
and then follow that with a series of chained methods provided by Cypress to interact with the browser. -
The first method is
.visit('/signup')
. Because we configured ourbaseUrl
earlier, we don’t need to provide the full path here. Simply append whatever comes afterhttp://0.0.0.0:8081
. -
Chain
.visit('/signup')
with.url()
, which receives the current URL. -
Chain .url() with an assertion using .should(). Pass it ...