Basic
- Testing a basic (email+password) authentication.
Summary
- In
db-utils,implement thecreateUserutility, following the steps. - Mention the
asyncDisposefor clean up of the created user. Handy! createUsercreates a test user. You might've heard that "test users" should be avoided. Talk about the difference between the two (we aren't creating a user that acts and asserts on internals; "test user" simply means an actual user record we created for test purposes).
- Create new test at
tests/e2e/authentication-basic.test.ts. - Create a new test case for successful authentication using email and password.
- In the test, use the newly created
createUser()utility, which generates a new user and creates it in the database. - Log in by filling the log in form as the user would.
- Assert that the authentication is successful based on the user profile link being visible on the screen.
npm run test:e2e.
- Another test case in the same file focused on displaying an error when authentication fails.
- Similar steps but no setup so the user doesn't exist.
- Assert the error message being shown (correct role and text).
npm run test:e2e.