Skip to content

Commit d5add66

Browse files
committed
fix(igx-ts): update the angular templates to use vite with playwright
1 parent ed4d1dd commit d5add66

27 files changed

Lines changed: 197 additions & 82 deletions

File tree

packages/igx-templates/igx-ts-legacy/bullet-graph/default/files/src/app/__path__/__filePrefix__.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
33
import { IgxBulletGraphModule } from 'igniteui-angular-gauges';
44
import { <%=ClassName%> } from './<%=filePrefix%>';
5+
import * as igGauges from 'igniteui-angular-gauges';
56

67
describe('<%=ClassName%>', () => {
78
let component: <%=ClassName%>;
89
let fixture: ComponentFixture<<%=ClassName%>>;
910

11+
// mock method specific to BulletGraph
12+
vi.spyOn(igGauges.XamBulletGraph.prototype, 'fb').mockImplementation(() => { /* mock */ });
13+
1014
beforeEach(async () => {
1115
await TestBed.configureTestingModule({
1216
declarations: [<%=ClassName%>],

packages/igx-templates/igx-ts-legacy/custom-templates/fintech-grid/files/src/app/__path__/__filePrefix__.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ describe('<%=ClassName%>', () => {
1414
declarations: [ <%=ClassName%> ],
1515
imports: [ FormsModule, BrowserAnimationsModule,
1616
IgxGridModule, IgxDialogModule, IgxCategoryChartModule,
17-
IgxButtonModule, IgxSwitchModule, IgxSliderModule, IgxCheckboxModule ]
17+
IgxButtonModule, IgxSwitchModule, IgxSliderModule, IgxCheckboxModule ],
18+
teardown: { destroyAfterEach: false }
1819
})
1920
.compileComponents();
2021
});

packages/igx-templates/igx-ts-legacy/linear-gauge/default/files/src/app/__path__/__filePrefix__.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
33
import { IgxLinearGaugeModule } from 'igniteui-angular-gauges';
44
import { <%=ClassName%> } from './<%=filePrefix%>';
5+
import * as gauges from 'igniteui-angular-gauges';
56

67
describe('<%=ClassName%>', () => {
78
let component: <%=ClassName%>;
89
let fixture: ComponentFixture<<%=ClassName%>>;
910

11+
// mock method specific to LinearGauge
12+
vi.spyOn(gauges.XamLinearGaugeView.prototype, 'ar').mockImplementation(() => { /* mock */ });
13+
1014
beforeEach(async () => {
1115
await TestBed.configureTestingModule({
1216
declarations: [<%=ClassName%>],

packages/igx-templates/igx-ts-legacy/projects/_base/files/__dot__azure/azure-pipelines.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ steps:
1919
continueOnError: true
2020
- script: npm run build
2121
displayName: 'Build the project'
22+
- script: npx playwright install chromium-headless-shell
23+
displayName: 'Install Playwright browsers'
2224
- script: npm run test -- --watch=false --browsers ChromeHeadless
2325
displayName: 'Run tests'
26+
env:
27+
CI: 'true'

packages/igx-templates/igx-ts-legacy/projects/_base/files/__dot__github/workflows/node.js.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ jobs:
3232
- run: npm i # replace with 'npm ci' after committing lock file from first install
3333
- run: npm run lint
3434
- run: npm run build
35+
- name: Install Playwright browsers
36+
run: npx playwright install chromium-headless-shell
3537
- run: npm run test -- --watch=false --browsers ChromeHeadless
38+
env:
39+
CI: 'true'

packages/igx-templates/igx-ts-legacy/projects/_base/files/angular.json

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,7 @@
100100
}
101101
},
102102
"test": {
103-
"builder": "@angular/build:karma",
104-
"options": {
105-
"polyfills": [
106-
"zone.js",
107-
"zone.js/testing"
108-
],
109-
"tsConfig": "tsconfig.spec.json",
110-
"inlineStyleLanguage": "scss",
111-
"assets": [
112-
"src/favicon.ico",
113-
"src/assets"
114-
],
115-
"styles": ["src/styles.scss"],
116-
"stylePreprocessorOptions": {
117-
"includePaths": ["node_modules"]
118-
}
119-
}
103+
"builder": "@angular/build:unit-test"
120104
},
121105
"lint": {
122106
"builder": "@angular-eslint/builder:lint",

packages/igx-templates/igx-ts-legacy/projects/_base/files/package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "ng serve -o",
77
"build": "ng build",
88
"watch": "ng build --watch --configuration development",
9-
"test": "node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng test",
9+
"test": "vitest --browser",
1010
"lint": "ng lint"
1111
},
1212
"private": true,
@@ -27,22 +27,19 @@
2727
"zone.js": "~0.16.0"
2828
},
2929
"devDependencies": {
30+
"@analogjs/vite-plugin-angular": "^2.3.1",
3031
"@angular/build": "~21.2.1",
3132
"@angular/cli": "~21.2.1",
3233
"@angular/compiler-cli": "~21.2.0",
3334
"@eslint/js": "^10.0.1",
34-
"@types/jasmine": "~5.1.4",
35+
"@vitest/browser-playwright": "^4.1.0",
3536
"angular-eslint": "~21.3.0",
3637
"eslint": "^10.0.2",
3738
"igniteui-cli": "~<%=cliVersion%>",
38-
"jasmine-core": "~5.12.1",
39-
"karma": "~6.4.4",
40-
"karma-chrome-launcher": "~3.2.0",
41-
"karma-coverage": "~2.2.1",
42-
"karma-jasmine": "~5.1.0",
43-
"karma-jasmine-html-reporter": "~2.1.0",
39+
"playwright": "^1.58.2",
4440
"prettier": "^3.8.1",
4541
"typescript": "~5.9.3",
46-
"typescript-eslint": "8.56.1"
42+
"typescript-eslint": "8.56.1",
43+
"vitest": "^4.1.0"
4744
}
4845
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { getTestBed } from '@angular/core/testing';
2+
import {
3+
BrowserDynamicTestingModule,
4+
platformBrowserDynamicTesting
5+
} from '@angular/platform-browser-dynamic/testing';
6+
import 'zone.js';
7+
import 'zone.js/testing';
8+
9+
// guard against multiple initialization
10+
if (!(globalThis as any).__angular_testbed_initialized__) {
11+
getTestBed().initTestEnvironment(
12+
BrowserDynamicTestingModule,
13+
platformBrowserDynamicTesting()
14+
);
15+
16+
(globalThis as any).__angular_testbed_initialized__ = true;
17+
}
18+
19+
afterEach(() => {
20+
getTestBed().resetTestingModule();
21+
});

packages/igx-templates/igx-ts-legacy/projects/_base/files/tsconfig.spec.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
"compilerOptions": {
66
"outDir": "./out-tsc/spec",
77
"types": [
8-
"jasmine"
8+
"vitest/globals"
99
]
1010
},
11+
"files": [
12+
"src/test.ts"
13+
],
1114
"include": [
1215
"src/**/*.spec.ts",
1316
"src/**/*.d.ts"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// <reference types="vitest" />
2+
import { defineConfig } from 'vitest/config';
3+
import { playwright } from '@vitest/browser-playwright'
4+
import angular from '@analogjs/vite-plugin-angular';
5+
import path from 'path';
6+
7+
// https://vitejs.dev/config/
8+
export default defineConfig({
9+
plugins: [angular()],
10+
test: {
11+
globals: true,
12+
setupFiles: ['./src/test.ts'],
13+
include: ['src/**/*.spec.ts'],
14+
browser: {
15+
enabled: true,
16+
provider: playwright(),
17+
instances: [
18+
{
19+
browser: 'chromium'
20+
},
21+
],
22+
}
23+
},
24+
resolve: {
25+
mainFields: ['module'],
26+
alias: {
27+
'igniteui-theming': path.resolve(__dirname, 'node_modules/igniteui-theming')
28+
}
29+
},
30+
server: {
31+
open: true,
32+
port: 3003
33+
}
34+
})

0 commit comments

Comments
 (0)