test(web): stub SvelteKit app modules suite-wide so no test loads the client runtime (#3943)
release / govulncheck (push) Successful in 32s
release / web (push) Successful in 1m25s
release / go (push) Successful in 1m41s
release / integration (push) Successful in 4m55s
release / android (push) Successful in 6m15s
release / Build signed APK (releases and dev) (push) Successful in 6m42s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 2m4s
release / Verify release artifacts (tag releases only) (push) Skipped
release / govulncheck (push) Successful in 32s
release / web (push) Successful in 1m25s
release / go (push) Successful in 1m41s
release / integration (push) Successful in 4m55s
release / android (push) Successful in 6m15s
release / Build signed APK (releases and dev) (push) Successful in 6m42s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 2m4s
release / Verify release artifacts (tag releases only) (push) Skipped
The home page reaches the real $app/navigation through AlbumCard and AlbumMenu. That loads SvelteKit's client runtime, whose $app/paths reads __SVELTEKIT_PAYLOAD__ at module load. The global is only there when the kit plugin's define reaches the module, and under vitest that is not reliable: page.test.ts failed to load on CI run 6576 and passed on its re-run. #374 was the same class of failure. vitest.setup.ts now mocks $app/navigation, $app/state and $app/paths for every test. Per-file mocks still win. A small guard test fails if the suite-wide mocks are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, test, vi } from 'vitest';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
|
||||
// Guards the suite-wide $app mocks in vitest.setup.ts (#3943). If they are
|
||||
// removed, tests that never mock $app themselves go back to loading
|
||||
// SvelteKit's client runtime, which fails at module load on some CI runs.
|
||||
describe('suite-wide SvelteKit app-module mocks', () => {
|
||||
test('$app/navigation is the mock, not the client runtime', () => {
|
||||
expect(vi.isMockFunction(goto)).toBe(true);
|
||||
});
|
||||
|
||||
test('$app/state gives a page at the root URL', () => {
|
||||
expect(page.url.pathname).toBe('/');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user