Test accepted and rejected cases
Create accepted and rejected cases for an order-ID pattern, then change the pattern to inspect a failing test.
Define the intended format
This guide uses ORD- followed by four ASCII digits. Select JavaScript, remove all flags, and use:
^ORD-[0-9]{4}$
Add positive and negative cases
- Open Unit Tests.
- Select Add unit test for each row.
- Set Assertion target to regex.
- Select the expected result in Assertion.
| Input | Criterion | Purpose |
|---|---|---|
ORD-0042 | does match | Ordinary accepted value |
ORD-9999 | does match | Four digits |
ORD-42 | does not match | Too few digits |
ORD-00000 | does not match | Too many digits |
XORD-0001 | does not match | Extra prefix |
| Empty input | does not match | Missing value |
- Select Run tests.
- Verify that all expectations pass.
If the list hides some results, select Show all tests in Unit test actions.
Inspect a failing test
- Change
{4}to{2,4}. - Run the same tests.
- Inspect the failure for
ORD-42. - Restore
{4}. - Run the tests again.
The negative case fails because the changed pattern accepts two-digit IDs. Restoring {4} restores the required format.
Include a line-ending boundary
Without m, the JavaScript pattern rejects ORD-0042\n. Enabling m permits a match on the first line.
Here, \n represents an actual newline, rather than two typed characters.
Keep m disabled for this identifier field. A full-match comparison can also guard against a later flag change.
The classification guide provides an executable version of that additional check.
Choose tests or multiple strings
Unit tests record expected outcomes and are included in Free. Multiple test strings show how one pattern behaves across separate editable inputs and require Pro.
On Free, you can inspect inputs one at a time or keep pass/fail expectations in unit tests. A saved workspace preserves the unit tests for later changes.