Introduction
I wanted to create some tests for tsParticles (leave a star if you want 🌟, it's free 👀), and I didn't know anything about t...
For further actions, you may consider blocking this person and/or reporting abuse
Great tutorial, thank you!
I tried for like 3 Hours to test my simple typescript code with karma+jasime (because angular is using it so how hard can it be)...
Looked 2mins on this guide and it works like a charme thank you!
Thanks @matteobruni quite helpful.
I was able to test APIs with minor adjustments.
For context: My source is in
src/tsincluding tests undersrc/ts/test. My compiles produce one js (undersrc/js-tmp) per source ts (undersrc/ts). My dists cherry-pick from js-tmp (i.e., exclude tests, ...).`
OMG finally. I tried to add chai testing to my first typescript app instead of karma, all examples inevitable ended with 'Cannot use import statement outside a module'. Tried babel and configured all jsons possible with no luck.
This one finally highlighted the critical part I needed, and because the example is simple and concise it wasn't lost - env TS_NODE_COMPILER_OPTIONS='{"module": "commonjs" }'
many thanks
'env' is not recognized as an internal or external command,
If you are on Windows
envneeds to be replaced withset, at least this is what I've read googling around.That command is related to
ts-nodeas you can read hereYes, but i had to add
&&.set TS_NODE_COMPILER_OPTIONS={\"module\": \"commonjs\" } && mocha -r ts-node/register 'tests/**/*.ts'Damn windows, I just wasted the last 24hrs just because of this😩!
Thanks a lot.
I have been using npmjs.com/package/cross-env for cross platform support
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/home//node_modules/ts-node/register not supported resolving ES modules imported from /home/mikkel/src//node_modules/mocha/lib/esm-utils.js
Did you mean to import ts-node/register/index.js?
Is pretty much what I get no matter what tutorial I follow.
Is
env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }'equivalent of adding this to your tsconfig.jsonIt depends if you need that in your tsconfig, which was not my case
Thanks, was very helpful on a project of mine.
Very helpful article.