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

Follow-up on question to @ava/typescript maintainers #1234

Closed
cspotcode opened this issue Feb 22, 2021 · 5 comments
Closed

Follow-up on question to @ava/typescript maintainers #1234

cspotcode opened this issue Feb 22, 2021 · 5 comments

Comments

@cspotcode
Copy link
Collaborator

Reminder to myself to follow-up on avajs/typescript#29

@wycats
Copy link

wycats commented Feb 23, 2021

I've been trying to use ava with ts-node. I managed to figure out that I needed tsnode/esm, but when I write .ts tests that use imports, I seem to unavoidably get:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/wycats/Code/wyst/node_modules/.pnpm/[email protected][email protected]/node_modules/ts-node/esm.mjs

@cspotcode
Copy link
Collaborator Author

I'll need a more complete reproduction to point you in the right direction.

@cspotcode
Copy link
Collaborator Author

@wycats looks like you're hitting an ava limitation. Tools like mocha detect if node should treat a file as CommonJS or as ESM. ava needs this to be explicitly configured.

Here is an example of ava and ts-node using import syntax compiled to and executed as CommonJS:
https://github.com/TypeStrong/ts-node-repros/runs/1964972170

Here is an example of ava and ts-node using import syntax compiled to and executed as ESM:
https://github.com/TypeStrong/ts-node-repros/runs/1964966424

@mesqueeb
Copy link

@cspotcode I have an issue with ts-node executing Ava tests, as soon as I added "type": "module" to the package json, ts-node complains that Ava doesn't have a default export.

Here is my thread on Ava, they think it's related to ts-node: avajs/ava#2698 (reply in thread)

Should I open a new issue for this?

@cspotcode
Copy link
Collaborator Author

@mesqueeb I've created an ava discussion thread. Please post your question over there. #1247

I've explained the difference between discussion threads and issues here: #1174

In short, proven * bugs and feature requests can be posted as issues, but questions should be posted in Discussions. If you're unsure if it's a bug or not, it's probably not a bug, so starting the conversation in Discussions is appropriate.

*We get a lot of issues which are posed as bugs, but are actually not. Best to start in Discussions and, where appropriate, create an issue requesting improved documentation once we you have a solution.

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

3 participants