Skip to content

Commit 2746ac6

Browse files
committed
feat/ migrate to vitest
1 parent d349e60 commit 2746ac6

14 files changed

Lines changed: 53 additions & 147 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
/out-tsc
77
/app-builds
88
/release
9+
/test-results
910
main.js
1011
src/**/*.js
11-
!src/karma.conf.js
1212
*.js.map
1313

1414
# dependencies

angular.json

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"index": "src/index.html",
2727
"polyfills": [
28-
"src/polyfills.ts"
28+
"zone.js"
2929
],
3030
"tsConfig": "src/tsconfig.app.json",
3131
"inlineStyleLanguage": "scss",
@@ -67,6 +67,12 @@
6767
"with": "src/environments/environment.prod.ts"
6868
}
6969
]
70+
},
71+
"testing": {
72+
"polyfills": [
73+
"zone.js",
74+
"zone.js/testing"
75+
]
7076
}
7177
},
7278
"defaultConfiguration": "production"
@@ -90,21 +96,28 @@
9096
}
9197
},
9298
"test": {
93-
"builder": "@angular/build:karma",
99+
"builder": "@angular/build:unit-test",
94100
"options": {
95-
"main": "src/test.ts",
96-
"polyfills": ["src/polyfills-test.ts"],
101+
"runner": "vitest",
97102
"tsConfig": "src/tsconfig.spec.json",
98-
"karmaConfig": "src/karma.conf.js",
99-
"inlineStyleLanguage": "scss",
100-
"assets": [
101-
"src/favicon.ico",
102-
"src/assets"
103+
"browsers": [
104+
"chromium"
103105
],
104-
"styles": [
105-
"src/styles.scss"
106+
"buildTarget": "angular-tauri:build:testing",
107+
"coverage": true,
108+
"coverageReporters": [
109+
"html",
110+
"lcovonly"
106111
],
107-
"scripts": []
112+
"reporters": [
113+
["default", { "summary": true }],
114+
[
115+
"html",
116+
{
117+
"outputFile": "test-results/vitest/index.html"
118+
}
119+
]
120+
]
108121
}
109122
},
110123
"lint": {

package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,23 @@
4343
"@ngx-translate/core": "17.0.0",
4444
"@ngx-translate/http-loader": "17.0.0",
4545
"@tauri-apps/cli": "2.9.5",
46-
"@types/jasmine": "5.1.13",
47-
"@types/jasminewd2": "2.0.13",
4846
"@types/node": "24.10.1",
4947
"@typescript-eslint/eslint-plugin": "8.48.1",
5048
"@typescript-eslint/parser": "8.48.1",
49+
"@vitest/browser-playwright": "4.0.15",
50+
"@vitest/coverage-v8": "4.0.15",
51+
"@vitest/ui": "4.0.15",
5152
"conventional-changelog-cli": "5.0.0",
5253
"eslint": "9.39.1",
5354
"eslint-plugin-import": "2.32.0",
5455
"eslint-plugin-jsdoc": "61.4.1",
5556
"eslint-plugin-prefer-arrow": "1.2.3",
56-
"jasmine-core": "5.13.0",
57-
"jasmine-spec-reporter": "7.0.0",
58-
"karma": "6.4.4",
59-
"karma-chrome-launcher": "3.2.0",
60-
"karma-coverage-istanbul-reporter": "3.0.3",
61-
"karma-jasmine": "5.1.0",
62-
"karma-jasmine-html-reporter": "2.1.0",
57+
"jsdom": "27.2.0",
6358
"npm-run-all": "4.1.5",
59+
"playwright": "1.57.0",
6460
"ts-node": "10.9.2",
6561
"typescript": "5.9.3",
62+
"vitest": "4.0.15",
6663
"wait-on": "9.0.3",
6764
"webdriver-manager": "13.0.2"
6865
},

src/app/app.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import {TauriService} from './core/services';
55
import {provideRouter} from '@angular/router';
66

77
describe('AppComponent', () => {
8-
beforeEach(waitForAsync(() => {
9-
TestBed.configureTestingModule({
8+
beforeEach(async() => {
9+
await TestBed.configureTestingModule({
1010
declarations: [],
1111
imports: [AppComponent, TranslateModule.forRoot()],
1212
providers: [provideRouter([]), TauriService]
1313
}).compileComponents();
14-
}));
14+
});
1515

16-
it('should create the app', waitForAsync(() => {
16+
it('should create the app', () => {
1717
const fixture = TestBed.createComponent(AppComponent);
1818
const app = fixture.debugElement.componentInstance;
1919
expect(app).toBeTruthy();
20-
}));
20+
});
2121
});

src/app/detail/detail.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ describe('DetailComponent', () => {
88
let component: DetailComponent;
99
let fixture: ComponentFixture<DetailComponent>;
1010

11-
beforeEach(waitForAsync(() => {
12-
TestBed.configureTestingModule({
11+
beforeEach(async() => {
12+
await TestBed.configureTestingModule({
1313
declarations: [],
1414
imports: [DetailComponent, TranslateModule.forRoot()],
1515
providers: [provideRouter([])]
1616
}).compileComponents();
17-
}));
17+
});
1818

1919
beforeEach(() => {
2020
fixture = TestBed.createComponent(DetailComponent);
@@ -26,10 +26,10 @@ describe('DetailComponent', () => {
2626
expect(component).toBeTruthy();
2727
});
2828

29-
it('should render title in a h1 tag', waitForAsync(() => {
29+
it('should render title in a h1 tag', () => {
3030
const compiled = fixture.debugElement.nativeElement;
3131
expect(compiled.querySelector('h1').textContent).toContain(
3232
'PAGES.DETAIL.TITLE'
3333
);
34-
}));
34+
});
3535
});

src/app/home/home.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ describe('HomeComponent', () => {
88
let component: HomeComponent;
99
let fixture: ComponentFixture<HomeComponent>;
1010

11-
beforeEach(waitForAsync(() => {
12-
TestBed.configureTestingModule({
11+
beforeEach(async () => {
12+
await TestBed.configureTestingModule({
1313
declarations: [],
1414
imports: [HomeComponent, TranslateModule.forRoot()],
1515
providers: [provideRouter([])]
1616
}).compileComponents();
17-
}));
17+
});
1818

1919
beforeEach(() => {
2020
fixture = TestBed.createComponent(HomeComponent);
@@ -26,10 +26,10 @@ describe('HomeComponent', () => {
2626
expect(component).toBeTruthy();
2727
});
2828

29-
it('should render title in a h1 tag', waitForAsync(() => {
29+
it('should render title in a h1 tag', () => {
3030
const compiled = fixture.debugElement.nativeElement;
3131
expect(compiled.querySelector('h1').textContent).toContain(
3232
'PAGES.HOME.TITLE'
3333
);
34-
}));
34+
});
3535
});

src/app/shared/components/page-not-found/page-not-found.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ describe('PageNotFoundComponent', () => {
66
let component: PageNotFoundComponent;
77
let fixture: ComponentFixture<PageNotFoundComponent>;
88

9-
beforeEach(waitForAsync(() => {
10-
void TestBed.configureTestingModule({
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
1111
declarations: []
1212
})
1313
.compileComponents();
1414

1515
fixture = TestBed.createComponent(PageNotFoundComponent);
1616
component = fixture.componentInstance;
1717
fixture.detectChanges();
18-
}));
18+
});
1919

2020
it('should create', () => {
2121
expect(component).toBeTruthy();

src/karma.conf.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/polyfills-test.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/polyfills.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)