Aman-Mittal opened a new issue, #410:
URL: https://github.com/apache/fineract-backoffice-ui/issues/410
Part of #403. **This is deliberately not a good first issue** — every other
batch under that epic is a codemod run, and this one is not.
## The problem
`scripts/codemod-jasmine-to-vitest.mjs` skips 19 specs and reports why. They
use constructs that carry zone or callback semantics rather than a spelling, so
there is no mechanical rewrite:
| Construct | Files | Why it cannot be codemodded |
| --- | --- | --- |
| `fakeAsync` + `tick()` | 5 | Angular's zone-based virtual clock. The
Vitest equivalent is usually `await fixture.whenStable()`, which is a different
shape of test — the assertions move relative to the awaits. |
| `flush()` | 9 | Drains the zone's macrotask queue. Same problem, and the
drained work is often an HTTP mock the spec then asserts on. |
| `done()` callbacks | 2 | Vitest takes a returned promise rather than a
`done` parameter. |
| `jasmine.clock()` | 1 | `vi.useFakeTimers()` has different semantics
around what it patches. |
| `createSpyObj` object form | 2 | Carries return values. A wrong guess
yields a spy returning `undefined` and a test that passes anyway — the worst
outcome. |
Concentrated in `src/app/core/` (11 of 19): the interceptors, `AuthService`,
`ConfigService`, `IdleService` and the error handler — the code most worth
having correct tests for, which is exactly why these should not be converted
carelessly.
## What to do
Get the list:
```bash
node scripts/codemod-jasmine-to-vitest.mjs --dry 2>&1 | sed -n '/left for a
human/,$p'
```
Then, per file, rewrite the async control flow rather than translating it.
Rules of thumb:
- `fakeAsync(() => { …; tick(); expect(…) })` usually becomes `async () => {
…; await fixture.whenStable(); expect(…) }`.
- `flush()` after an HTTP mock usually becomes `await` on the flushed
request, then `await fixture.whenStable()`.
- `vi.useFakeTimers()` / `vi.advanceTimersByTime()` is available where a
real virtual clock is genuinely needed (`IdleService` is the honest case — it
counts down).
- A spec using `done()` becomes an `async` test returning a promise.
**One file per commit, and say in the PR what changed about the timing
model.** A migrated async spec that passes for the wrong reason — because an
assertion now runs before the thing it asserts on — is worse than the Karma
spec it replaced, and is not visible in a diff.
## Acceptance criteria
- [ ] The spec asserts the same behaviour it asserted before, not merely
that it passes
- [ ] No `fakeAsync`, `tick`, `flush` or `done` remains in the migrated file
- [ ] `npm run test:unit` passes, and the test count for that file is
unchanged
- [ ] `karma-baseline.json` updated
## Suggested order
Interceptors first (`correlation-id`, `loading`, `retry`, `error`) — they
are the smallest and share a shape, so the first one establishes the pattern
for the rest. Leave `IdleService` until last; it is the one with genuine timer
semantics.
Background:
[`DOCS/adr/0004-vitest-migration.md`](DOCS/adr/0004-vitest-migration.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]