Building Test Cases
How to design and build effective test cases
Test Cases
Each Magnitude test case navigates to a URL in a browser, executes Test Steps on the web application at that URL, and verifies any Checks along the way.
For example:
Configure Test Cases
Each test can additionally be configured with a different starting URL (defaults to the configured project url
in magnitude.config.ts
):
Test Steps
When you define a step, you provide a description for what Magnitude should do during that step, for example:
Each step should make sense on its own and describe a portion of the user flow.
Steps should only be specific enough that it’s clear from your app’s interface how to complete the step. For example - to log into an app, you don’t need to say type into each field or what buttons to press - just provide any necessary data and say “Log in”.
Checks
A check is a natural language visual assertion that you can add to any step in your test case.
assert
in other testing frameworks, except it can “see” the website and understand natural language descriptions.Examples of valid checks:
- “Only 3 todos should be listed”
- “Make sure image of giraffe is visible”
- “The response from the chat bot should make sense and answer the user’s question”
To actually use a check in a test case, chain it to a step
like this:
Test Data
You can provide additional test data relevant to specific step like this:
You can also provide completely freeform data by passing in a string instead of a key/value object:
Example of migrating a Playwright test case to Magnitude
A simple test case from the Playwright demo TODO app:
The same test case in Magnitude: