Example of logging in using JWT
- Test login UI form
- Use
cy.request()once to get user object and JWT - Before each test set the JWT and the user object in
localStoragebefore visiting the page - The opened page instantly has the user logged in
Copied from https://jasonwatmore.com/post/2018/08/06/nodejs-jwt-authentication-tutorial-with-example-api
npm run start:serverRuns the API at port 4000
Vue application copied from https://jasonwatmore.com/post/2018/07/06/vue-vuex-jwt-authentication-tutorial-example
npm run start:appRuns the web application at port 8081
The front-end SPA logs in and stores the JWT and user information in the localStorage item named user
All Ajax requests to the protected resources need to have Authorization header with the Bearer <token> value.
- cypress/e2e/using-ui-spec.cy.js tests the login user interface form
- cypress/e2e/spec.cy.js shows how to log in once using cy.request and then set the JWT in the
localStorageto log in instantly before each test

