Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I --require .ts files? #87

Open
trgsv opened this issue May 1, 2023 · 4 comments
Open

How can I --require .ts files? #87

trgsv opened this issue May 1, 2023 · 4 comments

Comments

@trgsv
Copy link

trgsv commented May 1, 2023

Hi, I would like to require a file, so it runs before all of my tests.
Example: ts-mocha -r test/setup.ts \"test/**/*.test.ts\"

If I run this I get the following error: TypeError: Unknown file extension ".ts".
If I try to run the setup.mjs file, which I had before, when I wasn't using typescript, all the imports in that file don't work, because they are from .ts files.

What's the best way to get this working with ts-mocha?

@pmark
Copy link

pmark commented May 7, 2023

Same here. Seems like a TypeScript test runner should know about .ts files.

@trgsv
Copy link
Author

trgsv commented Jul 1, 2023

I have the same issue. Is there anything new ?

I just decided to move forward and migrated to vitest.

@cope
Copy link

cope commented Nov 30, 2023

Same here :(

@SySagar
Copy link

SySagar commented Mar 1, 2024

This error has been a lot in the community. The suggested methods are :

  1. In tsconfig.json , update { "esModuleInterop": true,}
  2. use test script as : "mocha --loader ts-node/esm --timeout 60000 --exit"

However non have worked so well for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants