Skip to content

Commit 4c92bb7

Browse files
committed
test: try to fix unit tests with new vite version
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent aa27b5c commit 4c92bb7

7 files changed

Lines changed: 107 additions & 37 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ Vagrantfile
161161
/config/autoconfig.php
162162
clover.xml
163163
/coverage
164+
.vitest*/
165+
__screenshots__/
164166

165167
# Tests - dependencies
166168
tests/acceptance/vendor/

apps/files/src/services/Search.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('Search service', () => {
3535
searchNodes.mockImplementationOnce(() => {
3636
throw new Error('expected error')
3737
})
38-
expect(() => getContents('', { signal: new AbortController().signal })).rejects.toThrow('expected error')
38+
await expect(() => getContents('', { signal: new AbortController().signal })).rejects.toThrow('expected error')
3939
})
4040

4141
it('returns the search results and a fake root', async () => {

build/frontend-legacy/vitest.config.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export default defineConfig({
5757
coverage: {
5858
include: ['./apps/*/src/**', 'core/src/**'],
5959
exclude: ['**.spec.*', '**.test.*', '**.cy.*', 'core/src/tests/**'],
60-
provider: 'istanbul',
6160
reporter: ['lcov', 'text'],
6261
reportsDirectory: resolve(import.meta.dirname, '../../coverage/legacy'),
6362
},

build/frontend/vitest.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export default defineConfig({
5454
/* 'core/src/**', */
5555
],
5656
exclude: ['**.spec.*', '**.test.*', '**.cy.*', 'core/src/tests/**'],
57-
provider: 'istanbul',
5857
reporter: ['lcov', 'text'],
5958
reportsDirectory: resolve(import.meta.dirname, '../../coverage'),
6059
},
@@ -72,5 +71,11 @@ export default defineConfig({
7271
inline: [/@nextcloud\//],
7372
},
7473
},
74+
onUnhandledError(error) {
75+
// TODO: remove when this is fixed: https://github.com/nextcloud-libraries/nextcloud-vue/issues/8090
76+
if (error.message.includes('`fallbackFocus` was specified but was not a node, or did not return a node')) {
77+
return false
78+
}
79+
},
7580
},
7681
})

package-lock.json

Lines changed: 75 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"sass:watch": "sass --watch --load-path core/css core/css/ $(for cssdir in $(find apps -mindepth 2 -maxdepth 2 -name \"css\"); do if ! $(git check-ignore -q $cssdir); then printf \"$cssdir \"; fi; done)",
3030
"stylelint": "stylelint $(for appdir in $(ls apps); do if ! $(git check-ignore -q \"apps/$appdir\"); then printf \"'apps/$appdir/**/*.{scss,vue}' \"; fi; done) 'core/**/*.{scss,vue}'",
3131
"stylelint:fix": "npm run stylelint -- --fix",
32-
"test": "build/demi.sh test",
33-
"test:coverage": "build/demi.sh test:coverage",
34-
"test:update-snapshots": "build/demi.sh test:update-snapshots",
35-
"test:watch": "build/demi.sh --parallel test:watch",
32+
"test": "vitest run",
33+
"test:coverage": "vitest run --coverage",
34+
"test:update-snapshots": "vitest run --update",
35+
"test:watch": "vitest --watch",
3636
"watch": "build/demi.sh --parallel watch"
3737
},
3838
"browserslist": [
@@ -77,9 +77,9 @@
7777
"@testing-library/jest-dom": "^6.9.1",
7878
"@testing-library/vue": "^8.1.0",
7979
"@types/dockerode": "^4.0.1",
80-
"@vitest/coverage-istanbul": "^4.1.4",
80+
"@vitest/coverage-v8": "^4.1.4",
8181
"@vue/test-utils": "^2.4.6",
82-
"@vue/tsconfig": "^0.9.0",
82+
"@vue/tsconfig": "^0.9.1",
8383
"@zip.js/zip.js": "^2.8.26",
8484
"concurrently": "^9.2.1",
8585
"cypress": "^15.14.0",
@@ -98,7 +98,7 @@
9898
"sass": "^1.99.0",
9999
"stylelint": "^17.8.0",
100100
"vite": "^7.3.2",
101-
"vitest": "^4.0.15"
101+
"vitest": "^4.1.4"
102102
},
103103
"engines": {
104104
"node": "^24.0.0",

vitest.config.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,23 @@
55

66
import { defineConfig } from 'vitest/config'
77

8-
// stub - for the moment see build/frontend/vitest.config.ts
98
export default defineConfig({
109
test: {
11-
projects: ['build/frontend*'],
10+
projects: [
11+
'build/frontend*',
12+
],
13+
onUnhandledError(error) {
14+
// TODO: remove when this is fixed: https://github.com/nextcloud-libraries/nextcloud-vue/issues/8090
15+
if (error.message.includes('`fallbackFocus` was specified but was not a node, or did not return a node')) {
16+
return false
17+
}
18+
},
19+
},
20+
server: {
21+
watch: {
22+
ignored(path: string) {
23+
return !/(\/|build\/frontend[^/]*\/)(apps|core)\/(src|tests)\//.test(path)
24+
},
25+
},
1226
},
1327
})

0 commit comments

Comments
 (0)