Your development workspace
This app is private. Sign in with your authorized Google account.
When a parameterized test repeats a long shared behavior in every case name, put that behavior in a meaningful describe group and give each child a concise distinguishing input or scenario label. Name empty inputs explicitly instead of producing a blank test name.
| 1 | const hasMode = (query: string) => new URLSearchParams(query).has('mode'); |
| 2 | it.each(['', '?tag=tools'])('rejects a query without a mode: %s', (query) => { |
| 3 | expect(hasMode(query)).toBe(false); |
| 4 | }); |
Explanation (EN)
Every case repeats the behavior and the empty query has no visible distinguishing label.
Objašnjenje (HR)
Svaki slucaj ponavlja ponasanje, a prazan upit nema vidljivu oznaku.
| 1 | const hasMode = (query: string) => new URLSearchParams(query).has('mode'); |
| 2 | describe('rejects a query without a mode', () => { |
| 3 | it.each(['', '?tag=tools'].map((query) => ({ query, label: query || '(no query)' })))( |
| 4 | '$label', |
| 5 | ({ query }) => { expect(hasMode(query)).toBe(false); } |
| 6 | ); |
| 7 | }); |
Explanation (EN)
The group names the shared behavior and each reported child identifies the actual input, including the empty-query case.
Objašnjenje (HR)
Grupa imenuje zajednicko ponasanje, a svaki podtest razlikuje ulaz, ukljucujuci prazan upit.
Use a case label or supported title interpolation while passing the original input unchanged to the test. Keep invalid whitespace/newline values visible with JSON formatting when needed. For object rows, prefer a scenario label over a large serialized fixture. Verify title interpolation against the installed runner rather than assuming a callback computes names.
Oznaka slucaja ne smije promijeniti izvorni ulaz. Za nevidljive znakove koristi JSON prikaz. Za objekte daj ime scenariju umjesto velikog ispisa fixturea. Provjeri podrzani API instaliranog runnera.
Do not add describe only to repeat the file/module name or add indentation. A small table with already concise, self-contained names can stay flat. A group must describe a real shared behavior, setup or edge condition.
Ne dodaj describe samo radi ponavljanja imena modula ili uvlacenja. Kratka tablica s jasnim samostalnim imenima moze ostati ravna. Grupa mora opisivati stvarno zajednicko ponasanje, setup ili granicni uvjet.
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).