Переглянути джерело

build: upgrade vite to 5.4.x, vitest to 2.x and related vite packages (#8459)

* build: upgrade vite to 5.x, vitest to 2.x and related vite packages

* upgrade vitest-ui and coverage

* pass empty set to fix type error and update snap

* set ignoreEmptyLines to false

* update threshold

* update coverage threshold

* downgrade vite-plugin-pwa as its better to push separately with testing

* add package resolutions for strip-ansi, string-width and wrap-ansi

* disable pwa

* only add resolution for strip-ansi
Aakansha Doshi 10 місяців тому
батько
коміт
51ea184938

+ 9 - 8
package.json

@@ -21,8 +21,8 @@
     "@types/react-dom": "18.2.0",
     "@types/socket.io-client": "3.0.0",
     "@vitejs/plugin-react": "3.1.0",
-    "@vitest/coverage-v8": "0.33.0",
-    "@vitest/ui": "0.32.2",
+    "@vitest/coverage-v8": "2.0.5",
+    "@vitest/ui": "2.0.5",
     "chai": "4.3.6",
     "dotenv": "16.0.1",
     "eslint-config-prettier": "8.5.0",
@@ -36,13 +36,13 @@
     "prettier": "2.6.2",
     "rewire": "6.0.0",
     "typescript": "4.9.4",
-    "vite": "5.0.12",
-    "vite-plugin-checker": "0.6.1",
+    "vite": "5.4.2",
+    "vite-plugin-checker": "0.7.2",
     "vite-plugin-ejs": "1.7.0",
     "vite-plugin-pwa": "0.17.4",
-    "vite-plugin-svgr": "2.4.0",
-    "vitest": "1.6.0",
-    "vitest-canvas-mock": "0.3.2"
+    "vite-plugin-svgr": "4.2.0",
+    "vitest": "2.0.5",
+    "vitest-canvas-mock": "0.3.3"
   },
   "engines": {
     "node": "18.0.0 - 20.x.x"
@@ -83,6 +83,7 @@
     "clean-install": "yarn rm:node_modules && yarn install"
   },
   "resolutions": {
-    "@types/react": "18.2.0"
+    "@types/react": "18.2.0",
+    "strip-ansi": "6.0.1"
   }
 }

+ 1 - 1
packages/excalidraw/tests/packages/events.test.tsx

@@ -43,7 +43,7 @@ describe("event callbacks", () => {
       // files
       {},
     );
-    expect(onChange.mock.lastCall[1].viewBackgroundColor).not.toBe(
+    expect(onChange.mock?.lastCall?.[1].viewBackgroundColor).not.toBe(
       origBackgroundColor,
     );
   });

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
packages/excalidraw/tests/scene/__snapshots__/export.test.ts.snap


+ 1 - 1
setupTests.ts

@@ -76,7 +76,7 @@ vi.mock(
           const url = this.urls[0];
 
           if (url.protocol !== "file:") {
-            return super.getContent();
+            return super.getContent(new Set());
           }
 
           // read local assets directly, without running a server

+ 12 - 4
vitest.config.mts

@@ -2,19 +2,27 @@ import { defineConfig } from "vitest/config";
 import { woff2BrowserPlugin } from "./scripts/woff2/woff2-vite-plugins";
 
 export default defineConfig({
-  // @ts-ignore
+  //@ts-ignore
   plugins: [woff2BrowserPlugin()],
   test: {
+    // Since hooks are running in stack in v2, which means all hooks run serially whereas
+    // we need to run them in parallel
+    sequence: {
+      hooks: 'parallel',
+    },
     setupFiles: ["./setupTests.ts"],
     globals: true,
     environment: "jsdom",
     coverage: {
       reporter: ["text", "json-summary", "json", "html", "lcovonly"],
+      // Since v2, it ignores empty lines by default and we need to disable it as it affects the coverage
+      // Additionally the thresholds also needs to be updated slightly as a result of this change
+      ignoreEmptyLines: false,
       thresholds: {
-        lines: 70,
+        lines: 66,
         branches: 70,
-        functions: 68,
-        statements: 70,
+        functions: 63,
+        statements: 66,
       },
     },
   },

Різницю між файлами не показано, бо вона завелика
+ 485 - 140
yarn.lock


Деякі файли не було показано, через те що забагато файлів було змінено