pass (a bill or inspection etc)afterCallback functions extend the test validation logic:
- Basic Test Steps::
shortest('Login with credentials', { username: process.env.TEST_USER, password: process.env.TEST_PWD }) - Adding Database Assertions::
- exist
afterGet the browser's stored authentication identifier (e.g., Clerk user ID) in a hook - Connecting to the database to verify the existence of a user record
- Sample code:
.after(async ({ page }) => { const userId = await page.evaluate( () => localStorage.getItem('clerk-user') ); const [user] = await db.select().from(users) .where(eq(users.clerkId, userId)); expect(user).toBeDefined(); });
- exist
Key Notes:
- Ensure that the test database uses an isolated environment (e.g. Docker container)
- For NoSQL databases, in-memory implementations can be used (e.g. MongoDB Memory Server)
- Pre-configured database connection parameters are required in CI/CD
This model is particularly suitable for B2B application testing where the full link state needs to be verified.
This answer comes from the articleShortest: an AI automated testing tool that uses natural language for end-to-end testingThe































