Skip to content

Commit 4a5f6fb

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

7 files changed

Lines changed: 85 additions & 23 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: 69 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
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",
8282
"@vue/tsconfig": "^0.9.0",
8383
"@zip.js/zip.js": "^2.8.26",

vitest.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ export default defineConfig({
1010
projects: [
1111
'build/frontend*',
1212
],
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+
},
1319
},
1420
server: {
1521
watch: {

0 commit comments

Comments
 (0)