Skip to content

Commit c8f252c

Browse files
committed
test(*): fixing test setup to start running chromium vitest
1 parent bdd83be commit c8f252c

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

.github/workflows/nodejs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
cache: 'npm'
3131
- name: Install packages
3232
run: npm install
33+
- name: Install Playwright Browsers
34+
run: npx playwright install --with-deps chromium
3335
- name: Lint Lib
3436
run: npm run lint:lib
3537
env:

angular.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,14 @@
172172
"builder": "@angular/build:unit-test",
173173
"options": {
174174
"tsConfig": "projects/igniteui-angular/tsconfig.spec.json",
175+
"browsers": ["chromium"],
175176
"buildTarget": "::test",
176-
"runnerConfig": "./vitest.config.ts"
177+
"runnerConfig": "./vitest.config.ts",
178+
"exclude": [
179+
"**/migrations/**",
180+
"**/schematics/**",
181+
"**/cypress/**"
182+
]
177183
}
178184
},
179185
"lint": {

projects/igniteui-angular/test-setup.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'zone.js';
2+
import 'zone.js/testing';
3+
14
import { getTestBed } from '@angular/core/testing';
25
import {
36
BrowserDynamicTestingModule,
@@ -28,8 +31,17 @@ expect.extend({
2831
}
2932
});
3033

31-
// Initialize the Angular testing environment
32-
getTestBed().initTestEnvironment(
33-
BrowserDynamicTestingModule,
34-
platformBrowserDynamicTesting(),
35-
);
34+
// Wait for Zone.js to be available
35+
if (typeof Zone === 'undefined') {
36+
throw new Error('Zone.js is required but not loaded');
37+
}
38+
39+
// Initialize the Angular testing environment only if not already initialized
40+
const testBed = getTestBed();
41+
if (!(testBed as any).platform) {
42+
testBed.initTestEnvironment(
43+
BrowserDynamicTestingModule,
44+
platformBrowserDynamicTesting(),
45+
{ teardown: { destroyAfterEach: true } }
46+
);
47+
}

projects/igniteui-angular/tsconfig.spec.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
"hammerjs"
1515
]
1616
},
17+
"files": [],
1718
"exclude": [
18-
"migrations/**/*.spec.ts",
19-
"schematics/**/*.spec.ts",
20-
"cypress/**/*.spec.ts"
19+
"migrations",
20+
"schematics",
21+
"cypress",
22+
"node_modules"
2123
],
2224
"include": [
2325
"**/*.spec.ts",

vitest.config.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ export default defineConfig({
2323
globals: true,
2424
setupFiles: ['./projects/igniteui-angular/test-setup.ts'],
2525
include: ['**/*.spec.ts'],
26+
exclude: [
27+
'**/node_modules/**',
28+
'**/dist/**',
29+
'**/migrations/**',
30+
'**/schematics/**',
31+
'**/cypress/**',
32+
],
2633
browser: {
2734
headless: true,
2835
provider: playwright(),
@@ -46,9 +53,10 @@ export default defineConfig({
4653
root: './projects/igniteui-angular',
4754
include: ['**/*.spec.ts'],
4855
exclude: [
49-
'migrations/**/*.spec.ts',
50-
'schematics/**/*.spec.ts',
51-
'cypress/**/*.spec.ts',
56+
'**/migrations/**',
57+
'**/schematics/**',
58+
'**/cypress/**',
59+
'**/node_modules/**',
5260
],
5361
},
5462
},

0 commit comments

Comments
 (0)