Skip to content

Commit 51a7e66

Browse files
committed
chore: migrate from Jest to Analog/Vitest
1 parent 284a074 commit 51a7e66

31 files changed

+6132
-2798
lines changed

.github/workflows/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ jobs:
6262
- name: Run Project Build
6363
run: yarn build
6464

65-
- name: Run Jest unit tests
65+
- name: Run Vitest unit tests
6666
if: ${{ !contains(github.event.head_commit.message, format('chore{0} release', ':')) }}
67-
run: yarn jest:ci
67+
run: yarn test:coverage
6868

69-
- name: Upload Jest coverage to Codecov
69+
- name: Upload Vitest coverage to Codecov
7070
if: ${{ !contains(github.event.head_commit.message, format('chore{0} release', ':')) }}
7171
uses: codecov/codecov-action@v4
7272
env:
7373
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7474
with:
7575
token: ${{ secrets.CODECOV_TOKEN }}
76-
directory: test/jest-coverage
76+
directory: coverage
7777
verbose: true
7878

7979
- name: Website Prod Build (served for Cypress)

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.md
22

3+
**/coverage/*.*
34
**/test/jest-coverage/*.*

.vscode/extensions.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
{
2-
"recommendations": [
3-
"andys8.jest-snippets",
4-
"angular.ng-template",
5-
"editorconfig.editorconfig",
6-
"esbenp.prettier-vscode",
7-
"dbaeumer.vscode-eslint"
8-
]
2+
"recommendations": ["angular.ng-template", "editorconfig.editorconfig", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
93
}

.vscode/launch.json

+7-14
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,15 @@
1717
"webRoot": "${workspaceFolder}"
1818
},
1919
{
20+
"name": "Vitest - Debug Current Test File",
2021
"type": "node",
2122
"request": "launch",
22-
"name": "Jest Current Spec File",
23-
"program": "${workspaceFolder}/node_modules/.bin/jest",
24-
"args": [
25-
"--runInBand",
26-
"${fileBasename}",
27-
"--config",
28-
"${workspaceFolder}/test/jest.config.ts"
29-
],
30-
"console": "internalConsole",
31-
"internalConsoleOptions": "neverOpen",
32-
"disableOptimisticBPs": true,
33-
"windows": {
34-
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
35-
}
23+
"autoAttachChildProcesses": true,
24+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
25+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
26+
"args": ["run", "${relativeFile}", "--no-watch", "--config", "./vite.config.mts"],
27+
"smartStep": true,
28+
"console": "integratedTerminal"
3629
}
3730
]
3831
}

.vscode/tasks.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232
"problemMatcher": []
3333
},
3434
{
35-
"label": "Run Jest Tests with Coverage",
35+
"label": "Run Vitest with Coverage",
3636
"type": "shell",
37-
"command": "yarn jest:coverage",
37+
"command": "yarn test:coverage",
3838
"problemMatcher": []
3939
},
4040
{
41-
"label": "Run Jest Watch",
41+
"label": "Run Vitest Watch",
4242
"type": "shell",
43-
"command": "yarn jest:watch",
43+
"command": "yarn test:watch",
4444
"problemMatcher": []
4545
},
4646
{
@@ -50,4 +50,4 @@
5050
"problemMatcher": []
5151
}
5252
]
53-
}
53+
}

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[![Actions Status](https://github.com/ghiscoding/Angular-Slickgrid/workflows/CI%20Build/badge.svg)](https://github.com/ghiscoding/Angular-Slickgrid/actions)
99
[![Cypress.io](https://img.shields.io/badge/tested%20with-Cypress-04C38E.svg?logo=cypress)](https://www.cypress.io/)
10-
[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest)
10+
[![Vitest](https://img.shields.io/badge/tested%20with-vitest-fcc72b.svg?logo=vitest)](https://vitest.dev/)
1111
[![codecov](https://codecov.io/gh/ghiscoding/Angular-Slickgrid/branch/master/graph/badge.svg)](https://codecov.io/gh/ghiscoding/Angular-Slickgrid)
1212

1313

@@ -139,7 +139,7 @@ Angular-Slickgrid uses `ngx-translate` library to support Locales, it is also re
139139
| 8-9 | 12.x |
140140
| 7 | 11.x |
141141

142-
### Tested with [Jest](https://jestjs.io/) (Unit Tests) - [Cypress](https://www.cypress.io/) (E2E Tests)
142+
### Tested with [Vitest](https://vitest.dev/) (Unit Tests) - [Cypress](https://www.cypress.io/) (E2E Tests)
143143
Slickgrid-Universal has **100%** Unit Test Coverage and all Angular-Slickgrid Examples are tested with [Cypress](https://www.cypress.io/) as E2E tests.
144144

145145
## Troubleshooting Section

angular.json

+10-22
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@
1414
"outputPath": "website",
1515
"index": "src/index.html",
1616
"main": "src/main.ts",
17-
"polyfills": [
18-
"zone.js"
19-
],
17+
"polyfills": ["zone.js"],
2018
"tsConfig": "tsconfig.app.json",
21-
"allowedCommonJsDependencies": [
22-
"@fnando/sparkline",
23-
"stream"
24-
],
19+
"allowedCommonJsDependencies": ["@fnando/sparkline", "stream"],
2520
"assets": [
2621
"src/assets",
2722
"src/favicon.ico",
@@ -46,13 +41,8 @@
4641
"output": "/assets/i18n"
4742
}
4843
],
49-
"styles": [
50-
"node_modules/@ng-select/ng-select/themes/default.theme.css",
51-
"src/styles.scss"
52-
],
53-
"scripts": [
54-
"node_modules/bootstrap/dist/js/bootstrap.min.js"
55-
],
44+
"styles": ["node_modules/@ng-select/ng-select/themes/default.theme.css", "src/styles.scss"],
45+
"scripts": ["node_modules/bootstrap/dist/js/bootstrap.min.js"],
5646
"vendorChunk": true,
5747
"extractLicenses": false,
5848
"buildOptimizer": false,
@@ -114,11 +104,11 @@
114104
"lint": {
115105
"builder": "@angular-eslint/builder:lint",
116106
"options": {
117-
"lintFilePatterns": [
118-
"src/**/*.ts",
119-
"src/**/*.html"
120-
]
107+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
121108
}
109+
},
110+
"test": {
111+
"builder": "@analogjs/vitest-angular:test"
122112
}
123113
}
124114
}
@@ -134,9 +124,7 @@
134124
},
135125
"cli": {
136126
"packageManager": "yarn",
137-
"schematicCollections": [
138-
"@angular-eslint/schematics"
139-
],
127+
"schematicCollections": ["@angular-eslint/schematics"],
140128
"analytics": false
141129
}
142-
}
130+
}

eslint.config.mjs

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import tseslint from 'typescript-eslint';
66

77
export default tseslint.config(
88
{
9-
ignores: [
10-
'.angular/*',
11-
'test/jest-coverage/',
12-
],
9+
ignores: ['.angular/*', 'coverage/', 'test/jest-coverage/'],
1310
},
1411
{
1512
extends: [
@@ -21,7 +18,7 @@ export default tseslint.config(
2118
],
2219
plugins: {
2320
cypress,
24-
n
21+
n,
2522
},
2623
// Everything in this config object targets our TypeScript files (Components, Directives, Pipes etc)
2724
files: ['**/*.ts'],
@@ -35,7 +32,10 @@ export default tseslint.config(
3532
'@typescript-eslint/ban-ts-comment': 'off',
3633
'@typescript-eslint/no-empty-function': 'off',
3734
'@typescript-eslint/no-unused-expressions': 'off',
38-
'@typescript-eslint/no-unused-vars': ['error', { 'argsIgnorePattern': '^_', 'destructuredArrayIgnorePattern': '^_', caughtErrors: 'none' }],
35+
'@typescript-eslint/no-unused-vars': [
36+
'error',
37+
{ argsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_', caughtErrors: 'none' },
38+
],
3939
'@typescript-eslint/no-explicit-any': 'off',
4040
'no-case-declarations': 'off',
4141
},
@@ -54,5 +54,5 @@ export default tseslint.config(
5454
'@angular-eslint/template/click-events-have-key-events': 'off',
5555
'@angular-eslint/template/interactive-supports-focus': 'off',
5656
},
57-
},
58-
);
57+
}
58+
);

global.d.ts

-1
This file was deleted.

package.json

+16-9
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@
2626
"cypress:ci": "cypress run --config-file test/cypress.config.ts",
2727
"lint": "eslint .",
2828
"lint:fix": "eslint --fix .",
29-
"jest:ci": "jest --runInBand --coverage=true --ci --config ./test/jest.config.ts",
30-
"jest:clear": "jest --clearCache",
31-
"jest:watch": "jest --config test/jest.config.ts --watch",
32-
"jest:coverage": "jest --config test/jest.config.ts --runInBand --coverage",
3329
"build:demo": "ng build --configuration=production --base-href=\"\"",
3430
"pack-lib": "npm pack ./dist",
3531
"preview:release": "release-it --only-version --dry-run",
3632
"prettier:check": "prettier --check **/*.{html,js,ts}",
3733
"prettier:write": "prettier --write **/*.{html,js,ts}",
3834
"release": "release-it --only-version",
39-
"serve:demo": "servor ./website index.html 4300"
35+
"serve:demo": "servor ./website index.html 4300",
36+
"test": "ng test",
37+
"test:watch": "ng test --watch",
38+
"test:coverage": "vitest --no-watch --coverage"
4039
},
4140
"repository": {
4241
"type": "git",
@@ -68,13 +67,17 @@
6867
},
6968
"devDependencies": {
7069
"@4tw/cypress-drag-drop": "^2.3.0",
70+
"@analogjs/platform": "^1.14.0",
71+
"@analogjs/vite-plugin-angular": "^1.14.0",
72+
"@analogjs/vitest-angular": "^1.14.0",
7173
"@angular-devkit/build-angular": "^18.2.14",
7274
"@angular-eslint/builder": "^18.4.3",
7375
"@angular-eslint/eslint-plugin": "^18.4.3",
7476
"@angular-eslint/eslint-plugin-template": "^18.4.3",
7577
"@angular-eslint/schematics": "^18.4.3",
7678
"@angular-eslint/template-parser": "^18.4.3",
7779
"@angular/animations": "^18.2.13",
80+
"@angular/build": "18",
7881
"@angular/cli": "^18.2.14",
7982
"@angular/common": "^18.2.13",
8083
"@angular/compiler": "^18.2.13",
@@ -90,6 +93,9 @@
9093
"@formkit/tempo": "^0.1.2",
9194
"@ng-select/ng-select": "^13.9.1",
9295
"@ngx-translate/http-loader": "^8.0.0",
96+
"@nx/angular": "^20.5.0",
97+
"@nx/devkit": "^20.5.0",
98+
"@nx/vite": "^20.5.0",
9399
"@popperjs/core": "^2.11.8",
94100
"@release-it/conventional-changelog": "^10.0.0",
95101
"@slickgrid-universal/composite-editor-component": "~5.13.0",
@@ -99,9 +105,9 @@
99105
"@slickgrid-universal/odata": "~5.13.0",
100106
"@slickgrid-universal/text-export": "~5.13.0",
101107
"@types/fnando__sparkline": "^0.3.7",
102-
"@types/jest": "^29.5.14",
103108
"@types/node": "^22.13.8",
104109
"@types/sortablejs": "^1.15.8",
110+
"@vitest/coverage-v8": "^3.0.8",
105111
"angular-eslint": "^18.4.3",
106112
"bootstrap": "^5.3.3",
107113
"custom-event-polyfill": "^1.0.7",
@@ -111,9 +117,7 @@
111117
"eslint": "^9.21.0",
112118
"eslint-plugin-cypress": "^4.1.0",
113119
"eslint-plugin-n": "^17.15.1",
114-
"jest": "^29.7.0",
115-
"jest-extended": "^4.0.2",
116-
"jest-preset-angular": "^14.5.3",
120+
"jsdom": "^22.0.0",
117121
"native-copyfiles": "^0.3.2",
118122
"ng-packagr": "^18.2.1",
119123
"ngx-bootstrap": "^18.1.3",
@@ -130,6 +134,9 @@
130134
"tslib": "^2.8.1",
131135
"typescript": "~5.5.4",
132136
"typescript-eslint": "^8.25.0",
137+
"vite": "^6.2.1",
138+
"vite-tsconfig-paths": "^4.3.2",
139+
"vitest": "^3.0.8",
133140
"zone.js": "~0.15.0"
134141
},
135142
"engines": {

src/app/app.component.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { TestBed } from '@angular/core/testing';
22
import { RouterTestingModule } from '@angular/router/testing';
3+
import { beforeEach, describe, expect, it } from 'vitest';
34

45
import { AppComponent } from './app.component';
56

0 commit comments

Comments
 (0)