Skip to content

Commit f2f3fd9

Browse files
committed
fix: downgrade chai to v4 for CommonJS compatibility
1 parent bd2ba0d commit f2f3fd9

File tree

3 files changed

+81
-17
lines changed

3 files changed

+81
-17
lines changed

AUTOMATED_TESTING.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,29 @@ git push
211211
- Standard practice for all package managers (npm, yarn, pnpm)
212212

213213
**Note**: The `pnpm-lock.yaml` file should **always** be committed to version control, never ignored.
214+
215+
### "require() of ES Module ... chai/index.js ... not supported"
216+
217+
**Cause**: Chai v6+ is an ES Module, but the tests are compiled to CommonJS
218+
219+
**Solution**: Use Chai v4 (the last CommonJS-compatible version)
220+
221+
```bash
222+
# Downgrade chai to v4
223+
pnpm remove chai @types/chai
224+
pnpm add -D chai@4 @types/chai@4
225+
226+
# Regenerate lockfile
227+
pnpm install
228+
```
229+
230+
**Why Chai 4?**
231+
- ✅ CommonJS compatible (works with TypeScript CommonJS output)
232+
- ✅ Stable and mature (used by millions of projects)
233+
- ✅ Same API as Chai 6 for our use cases
234+
- ✅ No breaking changes needed in tests
235+
236+
**Note**: The project uses TypeScript with CommonJS modules. To use Chai 6+, you would need to:
237+
- Switch to ES Modules in tsconfig.json (set `"module": "ES2020"`)
238+
- Update all imports to use `import` syntax
239+
- Configure Mocha for ESM

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,12 @@
303303
},
304304
"packageManager": "pnpm@8.15.9",
305305
"devDependencies": {
306-
"@types/chai": "^5.2.2",
306+
"@types/chai": "4",
307307
"@types/mocha": "^10.0.10",
308308
"@types/node": "^18.0.0",
309309
"@types/vscode": "^1.80.0",
310310
"@vscode/test-electron": "^2.5.2",
311-
"chai": "^6.2.0",
311+
"chai": "4",
312312
"conventional-changelog-cli": "^5.0.0",
313313
"glob": "^11.0.3",
314314
"mocha": "^11.7.4",

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)