Comments (7)
@jordansexton Thank you so much, that worked for me!
package.json
{
"type": "module"
}
tsconfig.json
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node",
}
}
.mocharc.json
{
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
from mocha-examples.
FWIW, here's a configuration for Mocha, TypeScript, and ESM that finally worked for me:
https://gist.github.com/jordansexton/2a0c3c360aa700cc9528e89620e82c3d
"node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"]
was the clincher.
from mocha-examples.
Thanks to all of you here, it helped me a lot :-)
I would simply add that one requirement is to use mocha@9
([email protected]
for me) as I was on mocha@8
and I was getting following error :
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
from mocha-examples.
Thanks. Time permitting I'll send a pull request with a sample. Till then, I'm subscribed to this thread and can answer questions.
from mocha-examples.
I'm looking for a solution on this as well
from mocha-examples.
Hi everyone else from search results.
This only works on node 16, haven't been able to get it to work on 18 or 20.
Newer nodes don't like, and don't need(?) the "experimental-specifier-resolution=node",
from mocha-examples.
Related Issues (20)
- selenium test is not working in latest chrome HOT 1
- Run all tests on CI HOT 5
- Broken link in docs HOT 1
- How to pass variables from a --file setup to all the tests? HOT 6
- Typescript root level hooks HOT 5
- Add an example for job summary HOT 4
- Add more examples for Express.js HOT 1
- typescript examples with commonjs not work with latest versuin, looks like mocha supports only esm
- Example needed for cli testing tool
- Remote control rauter
- TypeError: Unknown file extension ".ts" | HOT 7
- 🛠️ Repo: Move from TSLint to ESLint
- 🚀 Feature: Add examples for more modern on-the-fly transpilation tools
- 🚀 Feature: Add example of usage in a CommonJS project with Chai 5.x (ESM-only) HOT 1
- Improving test isolation in Workflow
- 🚀 Feature: Add example of a browser test
- 🚀 Feature: Add example with the xunit reporter
- 🚀 Feature: Add an example showing mocha+browser and mocha+node, where node imports JSDOM and browser uses global.window HOT 1
- 🚀 Feature: Add an example with the tdd UI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mocha-examples.