About: Full Stack Developer, mainly working in .NET with web technologies and mobile (Xamarin).
WWDC14 Attendee, when Swift was presented, a bit rusty but can work in Swift too.
Joined:
Mar 12, 2020
Mocha/Chai with TypeScript (2023 update)
Publish Date: Aug 13 '23
53 8
I wrote an article in 2020 for using Mocha/Chai in a TypeScript project, that I'm using in tsParticles (leave a star if you want 🌟, it's free 👀).
tsParticles - Easily create highly customizable JavaScript particles effects, confetti explosions and fireworks animations and use them as animated backgrounds for your website. Ready to use components available for React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Solid, Riot and Web Components.
tsParticles - TypeScript Particles
A lightweight TypeScript library for creating particles. Dependency free (*), browser ready and compatible with
React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Riot.js, Solid.js, and Web Components
"module": "commonjs" is worrying. It forces me to target commonjs. That's a nasty limitation, like "it's 2023 and you wish you could live in an ESM world, but good things are not for you if you want to be able to test".
You can target that only for testing, like I did. I did now some research and it seems that it could be possible but the issue is still opened so maybe it's like in a beta state or something
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /var/www/html/project-name/test/calculator.service.spec.ts
at new NodeError (node:internal/errors:399:5)
at Object.getFileProtocolModuleFormat as file:
at defaultGetFormat (node:internal/modules/esm/get_format:139:38)
at ESMLoader.defaultLoad (node:internal/modules/esm/load:83:20)
at ESMLoader.load (node:internal/modules/esm/loader:342:43)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:207:22)
at new ModuleJob (node:internal/modules/esm/module_job:63:26)
at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:231:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:184:34)
these are good updates and it works till restricted versions of mocha and chai
here is what I'm using
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"chai": "^4.3.7",
"cross-env": "^7.0.3",
"mocha": "^10.2.0",
"module": "commonjs"
is worrying. It forces me to target commonjs. That's a nasty limitation, like "it's 2023 and you wish you could live in an ESM world, but good things are not for you if you want to be able to test".