aboutsummaryrefslogtreecommitdiffstats
path: root/__tests__
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-08-24 16:51:18 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-08-26 17:27:22 +0200
commitc0b39bb9095b9e0421314c99d3ff0e149a21c435 (patch)
tree8d8ebdf0a9052e84dfd0df6b2e5d6f2580633c02 /__tests__
parentc6ec82203e3615f1493bbb230eea8e2fba9abfa8 (diff)
downloadnextcloud-server-c0b39bb9095b9e0421314c99d3ff0e149a21c435.tar.gz
nextcloud-server-c0b39bb9095b9e0421314c99d3ff0e149a21c435.zip
chore: Move from Jest to vitest
There are some benefits, like faster tests and thus saving CI time, but the main reason for me is: Jest still does not properly support ESM packages, this casues a lot of breaking stuff. Sometimes you need to adjust imports for mocking, and somethimes other random stuff break. Instead of wasting valuable developer lifetime we can use vitest which works perfectly with ESM. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/jest-setup.ts12
-rw-r--r--__tests__/mock-window.js5
-rw-r--r--__tests__/setup-testing-library.js5
-rw-r--r--__tests__/tsconfig.json6
4 files changed, 10 insertions, 18 deletions
diff --git a/__tests__/jest-setup.ts b/__tests__/jest-setup.ts
deleted file mode 100644
index 7ee7b7dcac8..00000000000
--- a/__tests__/jest-setup.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-import '@testing-library/jest-dom'
-
-// Mock `window.location` with Jest spies and extend expect
-import 'jest-location-mock'
-
-// Mock `window.fetch` with Jest
-import 'jest-fetch-mock'
diff --git a/__tests__/mock-window.js b/__tests__/mock-window.js
index 0daeea122d7..dbb689a4f2c 100644
--- a/__tests__/mock-window.js
+++ b/__tests__/mock-window.js
@@ -2,7 +2,12 @@
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+import { beforeEach } from 'vitest'
window.OC = { ...window.OC }
window.OCA = { ...window.OCA }
window.OCP = { ...window.OCP }
+
+beforeEach(() => {
+ window.location = new URL('http://nextcloud.local')
+})
diff --git a/__tests__/setup-testing-library.js b/__tests__/setup-testing-library.js
new file mode 100644
index 00000000000..9f0a55dd211
--- /dev/null
+++ b/__tests__/setup-testing-library.js
@@ -0,0 +1,5 @@
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: CC0-1.0
+ */
+import '@testing-library/jest-dom/vitest'
diff --git a/__tests__/tsconfig.json b/__tests__/tsconfig.json
deleted file mode 100644
index 489da623e1b..00000000000
--- a/__tests__/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "extends": "../tsconfig.json",
- "compilerOptions": {
- "verbatimModuleSyntax": false
- }
-}