Skip to content

Commit 1d2f84c

Browse files
authored
Merge pull request #123 from ModusCreateOrg/NO-TICKET-FIX-NPM-BUILD
Refactor test setup: standardize scrollIntoView function formatting and add Vitest type definitions
2 parents c10db00 + 3d0e228 commit 1d2f84c

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

frontend/src/setupTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ window.matchMedia =
2323
};
2424

2525
// Mock scrollIntoView - not implemented in JSDOM but used by Ionic components
26-
Element.prototype.scrollIntoView = function() {};
26+
Element.prototype.scrollIntoView = function () {};
2727

2828
// Run before each test SUITE
2929
beforeAll(() => {

frontend/src/types/vitest.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import 'vitest';
2+
3+
// Extend the expect interface with testing-library matchers
4+
declare global {
5+
// Add typings for Vitest global functions
6+
const describe: typeof import('vitest')['describe'];
7+
const it: typeof import('vitest')['it'];
8+
const test: typeof import('vitest')['test'];
9+
const expect: typeof import('vitest')['expect'];
10+
const vi: typeof import('vitest')['vi'];
11+
const beforeEach: typeof import('vitest')['beforeEach'];
12+
const afterEach: typeof import('vitest')['afterEach'];
13+
const beforeAll: typeof import('vitest')['beforeAll'];
14+
const afterAll: typeof import('vitest')['afterAll'];
15+
16+
// Extend the globalThis interface to allow assigning Vitest functions
17+
interface Window {
18+
expect: typeof import('vitest')['expect'];
19+
afterEach: typeof import('vitest')['afterEach'];
20+
beforeEach: typeof import('vitest')['beforeEach'];
21+
describe: typeof import('vitest')['describe'];
22+
it: typeof import('vitest')['it'];
23+
vi: typeof import('vitest')['vi'];
24+
beforeAll: typeof import('vitest')['beforeAll'];
25+
afterAll: typeof import('vitest')['afterAll'];
26+
}
27+
}

0 commit comments

Comments
 (0)