Skip to content

Commit 83b005b

Browse files
authored
Merge pull request #540 from ckeditor/i/539-vitest
Replace Karma/Jasmine with Vitest
2 parents affcfb9 + 065f0d3 commit 83b005b

16 files changed

Lines changed: 890 additions & 724 deletions

.circleci/config.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ jobs:
101101
- checkout
102102
- bootstrap_repository_command
103103
- browser-tools/install_chrome
104-
- browser-tools/install_firefox
105104
- run:
106105
name: Execute ESLint
107106
command: pnpm run lint
@@ -111,19 +110,6 @@ jobs:
111110
- run:
112111
name: Run unit tests
113112
command: pnpm run coverage
114-
- run:
115-
name: Verify the code coverage
116-
command: |
117-
#!/bin/bash
118-
119-
# Create the `nyc` directory.
120-
mkdir .nyc_output
121-
122-
# Copy results.
123-
cp coverage/coverage-final.json .nyc_output
124-
125-
# Verify results.
126-
npx nyc check-coverage --branches 100 --functions 100 --lines 100 --statements 100
127113
- run:
128114
name: Run e2e tests
129115
command: pnpm run test:e2e:ci

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,20 @@ To test it in production, use:
133133
pnpm run start --configuration production
134134
```
135135

136-
To run unit tests, use:
136+
To run unit tests once (without watch, Vitest + Chrome), use:
137137

138138
```bash
139139
pnpm run test
140140
```
141141

142+
The unit test suite runs in a real browser (Chrome) using Vitest browser mode.
143+
144+
To run unit tests in watch mode, use:
145+
146+
```bash
147+
pnpm run test:dev
148+
```
149+
142150
To run e2e tests, run:
143151

144152
```bash
@@ -154,6 +162,8 @@ To run coverage tests, run:
154162
pnpm run coverage
155163
```
156164

165+
The coverage report is generated in the `./coverage` directory.
166+
157167
Play with the application and make sure the component works properly.
158168

159169
## Releasing package

angular.json

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,10 @@
7878
}
7979
},
8080
"test": {
81-
"builder": "@angular-devkit/build-angular:karma",
81+
"builder": "@analogjs/vitest-angular:test",
8282
"options": {
83-
"main": "src/test.ts",
84-
"codeCoverageExclude": ["src/editor/**"],
85-
"polyfills": "src/polyfills.ts",
86-
"tsConfig": "tsconfig.spec.json",
87-
"karmaConfig": "karma.conf.js",
88-
"styles": [
89-
"ckeditor5/ckeditor5.css",
90-
"src/styles.css"
91-
],
92-
"scripts": [],
93-
"assets": [
94-
"src/favicon.ico",
95-
"src/assets"
96-
]
83+
"configFile": "vitest.config.mjs",
84+
"watch": true
9785
}
9886
}
9987
}

karma.conf.js

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

package.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
"postinstall": "node ./scripts/postinstall.js",
1010
"start": "ng serve",
1111
"build": "ng build --configuration production",
12-
"test": "ng test",
12+
"test": "ng test --watch=false",
13+
"test:dev": "ng test --watch",
1314
"test:e2e": "cypress run",
1415
"test:e2e:ci": "start-server-and-test 'pnpm run start' http://localhost:4200/ 'pnpm run test:e2e --quiet'",
1516
"test:scripts": "vitest --config ./scripts-tests/vitest.config.mjs --run",
16-
"coverage": "ng test --watch=false --code-coverage",
17+
"coverage": "ng test --watch=false --coverage",
1718
"lint": "eslint",
1819
"build-package": "ng-packagr -p src/ckeditor/ng-package.json",
1920
"release:prepare-changelog": "node scripts/preparechangelog.mjs",
@@ -36,6 +37,8 @@
3637
"zone.js": "~0.15.1"
3738
},
3839
"devDependencies": {
40+
"@analogjs/vite-plugin-angular": "^2.2.3",
41+
"@analogjs/vitest-angular": "^2.2.3",
3942
"@angular-devkit/build-angular": "^19.2.19",
4043
"@angular/cli": "^19.2.19",
4144
"@angular/compiler-cli": "^19.2.18",
@@ -45,9 +48,9 @@
4548
"@ckeditor/ckeditor5-dev-ci": "^54.2.0",
4649
"@ckeditor/ckeditor5-dev-release-tools": "^54.2.0",
4750
"@ckeditor/ckeditor5-dev-utils": "^54.2.0",
48-
"@types/jasminewd2": "^2.0.10",
4951
"@types/node": "^14.11.8",
50-
"@vitest/coverage-v8": "^4.0.15",
52+
"@vitest/browser-playwright": "^4.0.18",
53+
"@vitest/coverage-v8": "^4.0.18",
5154
"ckeditor5": "^47.0.0",
5255
"ckeditor5-premium-features": "^47.0.0",
5356
"css-loader": "^5.2.7",
@@ -58,17 +61,10 @@
5861
"fs-extra": "^10.0.1",
5962
"globals": "^16.1.0",
6063
"husky": "^8.0.2",
61-
"jasmine-core": "~3.8.0",
62-
"jasmine-spec-reporter": "~5.0.0",
63-
"karma": "^6.3.17",
64-
"karma-chrome-launcher": "~3.1.0",
65-
"karma-coverage": "^2.2.0",
66-
"karma-firefox-launcher": "^1.1.0",
67-
"karma-jasmine": "~4.0.1",
68-
"karma-jasmine-html-reporter": "^1.7.0",
6964
"lint-staged": "^10.4.0",
7065
"minimist": "^1.2.8",
7166
"ng-packagr": "^19.2.2",
67+
"playwright": "^1.52.0",
7268
"postcss-loader": "^4.3.0",
7369
"raw-loader": "^4.0.1",
7470
"semver": "^7",
@@ -79,7 +75,7 @@
7975
"typescript": "~5.5.0",
8076
"typescript-eslint": "^8.32.0",
8177
"upath": "^2.0.1",
82-
"vitest": "^4.0.15",
78+
"vitest": "^4.0.18",
8379
"webpack": "^5.94.0",
8480
"webpack-cli": "^5.1.4"
8581
},

0 commit comments

Comments
 (0)