fastify / demo

MIT License
27 stars 15 forks source link

Tests won't run due to esm or ts related issue #32

Closed berkerdemirer closed 4 weeks ago

berkerdemirer commented 1 month ago

Prerequisites

Fastify version

5

Plugin version

No response

Node.js version

22

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

latest

Description

Tests are not running.

Tried to run the tests but I guess there is something off with test runner and typescript. If I use the default runner then it cannot compile the .ts extension. if I use tsx then i get something like:

@fastify/autoload cannot import plugin at '/Users/berkerdemirer/git/sightsnap-server/src/plugins/external/clerk.ts'. To fix this error compile TypeScript to JavaScript or use 'ts-node' to run your app.

any idea how to solve this?

Link to code that reproduces the bug

No response

Expected Behavior

Tests should run

jean-michelet commented 1 month ago

It looks like you added an external plugin, did you edit anything else?

Can you give the diff between main on this repo and you current branch plz?

A reproduction repository could help too.

berkerdemirer commented 1 month ago

I actually tested out within the demo repo as well. I think the issue is related with the test runner. I am using webstorm atm and just try to invoke single test run through the IDE. Can't get it to work with either ts-node or tsx. But, i guess that's not really related with the repo.

image

jean-michelet commented 1 month ago

Regarding the autoloader error, does it work if you implement this: https://github.com/fastify/fastify-autoload?tab=readme-ov-file#override-typescript-detection-using-an-environment-variable

The autoloader should support tsx btw: https://github.com/fastify/fastify-autoload/blob/master/scripts/unit-typescript-tsx.js

jean-michelet commented 1 month ago

What is the state of this issue?

jean-michelet commented 4 weeks ago

Closed due to non-activity.