diff --git a/django/aiservice/core/languages/js_ts/prompts/react_testgen/system_prompt.md b/django/aiservice/core/languages/js_ts/prompts/react_testgen/system_prompt.md index 74a872d92..9d5f0e36e 100644 --- a/django/aiservice/core/languages/js_ts/prompts/react_testgen/system_prompt.md +++ b/django/aiservice/core/languages/js_ts/prompts/react_testgen/system_prompt.md @@ -111,6 +111,15 @@ If the component has no buttons, inputs, or interactive elements, you MUST still - Example: `const { rerender } = render(); rerender(); rerender();` - This produces update-phase markers that Codeflash needs for A/B comparison. +**Assertion Safety Rules (Reduce False Failures)** +- Do NOT assert specific `aria-label` values unless they are explicitly visible in the source code. +- Do NOT assert element counts (`getAllByRole(...).toHaveLength(N)`) unless the count is deterministic from props. +- Prefer `screen.getByText(...)` for visible text and `screen.getByRole('button')` for interactive elements. +- When asserting DOM structure, use `toBeInTheDocument()` instead of specific positions or counts. +- For components with dynamic data (lists, tables), assert that AT LEAST ONE item renders, not a specific count. +- Do NOT guess CSS classes or inline styles in assertions. +- Prefer querying by text content or role over testId — but if the source uses `data-testid`, prefer that. + **Anti-Patterns (Do NOT Do These)** - Do NOT write tests that only call `render()` without any interactions or rerenders — these produce only mount-phase markers, which are USELESS for optimization measurement. - Do NOT create wrapper components with manual render count variables.