Skip to content

Commit 0d88040

Browse files
authored
improve vitest hang (#1470)
* improve vitest hang * fmt * make types happy * fix types * fix
1 parent cbd26d2 commit 0d88040

File tree

6 files changed

+454
-391
lines changed

6 files changed

+454
-391
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ jobs:
8686

8787
- run: yarn test:nowatch
8888

89-
- run: yarn test:cov
90-
9189

9290
prepare-json-files:
9391
runs-on: ubuntu-latest # seperate job on Ubuntu for easy string manipulations (compared to Windows)

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"fuse.js": "^7.0.0",
3535
"http-server": "^14.1.1",
3636
"json-rpc-2.0": "^1.6.0",
37+
"node-fetch": "^3.3.2",
3738
"re-resizable": "^6.9.11",
3839
"react": "^18.2.0",
3940
"react-dom": "^18.2.0",
@@ -51,7 +52,7 @@
5152
"ts-node": "^10.9.1",
5253
"typescript": "^5.2.2",
5354
"uuid": "^9.0.1",
54-
"vitest": "^0.34.6",
55+
"vitest": "^1.3.1",
5556
"vscode-jsonrpc": "^8.1.0",
5657
"vscode-languageserver-protocol": "^3.17.5",
5758
"wasm-pack": "^0.12.1",
@@ -72,7 +73,6 @@
7273
"test": "vitest --mode development",
7374
"test:nowatch": "vitest run --mode development",
7475
"test:rust": "(cd src/wasm-lib && cargo test --all && cargo clippy --all --tests --benches)",
75-
"test:cov": "vitest run --coverage --mode development",
7676
"test:e2e:tauri": "E2E_TAURI_ENABLED=true TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' wdio run wdio.conf.ts",
7777
"simpleserver:ci": "yarn pretest && http-server ./public --cors -p 3000 &",
7878
"simpleserver": "yarn pretest && http-server ./public --cors -p 3000",
@@ -113,7 +113,6 @@
113113
"@tauri-apps/cli": "^1.5.6",
114114
"@types/crypto-js": "^4.1.1",
115115
"@types/debounce-promise": "^3.1.8",
116-
"@types/isomorphic-fetch": "^0.0.36",
117116
"@types/pixelmatch": "^5.2.6",
118117
"@types/pngjs": "^6.0.4",
119118
"@types/react-modal": "^3.16.3",
@@ -122,8 +121,7 @@
122121
"@types/wait-on": "^5.3.4",
123122
"@types/wicg-file-system-access": "^2020.9.6",
124123
"@types/ws": "^8.5.5",
125-
"@vitejs/plugin-react": "^4.1.1",
126-
"@vitest/coverage-istanbul": "^0.34.6",
124+
"@vitejs/plugin-react": "^4.2.1",
127125
"@wdio/cli": "^8.24.3",
128126
"@wdio/globals": "^8.24.3",
129127
"@wdio/local-runner": "^8.24.3",
@@ -144,10 +142,10 @@
144142
"prettier": "^2.8.0",
145143
"setimmediate": "^1.0.5",
146144
"tailwindcss": "^3.3.6",
147-
"vite": "^4.5.2",
145+
"vite": "^5.1.3",
148146
"vite-plugin-eslint": "^1.8.1",
149147
"vite-plugin-package-version": "^1.1.0",
150-
"vite-tsconfig-paths": "^4.2.1",
148+
"vite-tsconfig-paths": "^4.3.1",
151149
"vitest-webgl-canvas-mock": "^1.1.0",
152150
"wait-on": "^7.2.0",
153151
"yarn": "^1.22.19"

src/lang/KclSingleton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class KclManager {
211211
console.error('error parsing code', e)
212212
if (e instanceof KCLError) {
213213
this.kclErrors = [e]
214-
if (e.msg === 'file is empty') engineCommandManager.endSession()
214+
if (e.msg === 'file is empty') engineCommandManager?.endSession()
215215
}
216216
return null
217217
}

src/setupTests.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { WebSocket } from 'ws'
33
import { vi } from 'vitest'
44
import 'vitest-webgl-canvas-mock'
55

6+
import fetch from 'node-fetch'
7+
8+
// @ts-ignore
9+
globalThis.fetch = fetch
10+
611
class MockRTCPeerConnection {
712
createDataChannel() {
813
return

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const config = defineConfig({
3535
viteTsconfigPaths(),
3636
eslint(),
3737
version(),
38-
]
38+
],
3939
})
4040

4141
export default config

0 commit comments

Comments
 (0)