Jest -> ts-jest + Typescript does not appear to be working
See original GitHub issue🐛 Bug Report
In Fastify-Autoload 1.x jest tests + typescript worked with fastify-autoload with seemingly no issue as long as the includeTypescript: true
configuration was passed. With the new version it appears that has been removed in favor of automatically supporting ts-node. I don’t 100% know everything about ts-jest but I do not believe it uses ts-node and yet it worked before. It seems like this should still work.
To Reproduce
Steps to reproduce the behavior:
clone this repo - https://github.com/wolfejw86/fastify-typescript-starter
run npm install
run npm run test
see that fasitify-autoload is working correctly in https://github.com/wolfejw86/fastify-typescript-starter/blob/master/src/app.ts
In the same repo - upgrade fastify-swagger, fastify, fastify-plugin, and fastify-autoload all to the latest version by switching to the branch in progress(the 3.0 migration for fastify + typescript).
git checkout fastify-upgrade
npm install
npm run test
Notice fastify-autoload will no longer load any plugins.
fastify-autoload cannot import plugin at '/Users/johnwolfe/Desktop/repositories/fastify-typescript-starter/src/plugins/globalErrorHandler.ts'. To fix this error compile TypeScript to JavaScript or use 'ts-node' to run your app.
at findPlugins (node_modules/fastify-autoload/index.js:87:15)
at fastifyAutoload (node_modules/fastify-autoload/index.js:19:19)
Edit:
Additionally if I hardcode this line:
~It mostly works, but doesn’t load an index.ts
file in the services folder from:~ EDIT: it works fine - I did not correctly understand the new behavior of how autoload plugin handles nested folders
~I am waiting for fastify.ready()
but it seems like it’s firing before the second call to the autoload plugin has finished resolving or something.~ EDIT: It loads all modules correctly according to how Autoload uses nested folders as pathnames now.
Any help is appreciated 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
yes i’ll be happy to. i have kind of a crazy week but will knock it out over the weekend if that’s okay 😃
There should be no real difference between the two.