Closed osdiab closed 3 years ago
before trying
@ava/typescript
, I was just settingNODE_PATH
to.build-tsc
so that Node could find all the proper files.
Is your code still assuming this is the case? Unless you configure TypeScript to map src/
, the compiled JavaScript code is still trying to import src/
directly and that won't work. @ava/typescript
only rewrites the initial import, so you can select the TypeScript files rather than the build output.
(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)
Ah, I thought that @ava/typescript
would manage that because it had the rewritePaths
member - so I guess what exactly does that do, why does it it stop at the initial import? Makes sense though, guess would need to include the tsconfig-paths
plugin or keep including the custom NODE_PATH
to make it work as it was before.
@ava/typescript
lets you run npx ava src/test.ts
(or select src/
files in the config), plus compile your project for you so you don't forget.
I'm kinda confused how I'm supposed to properly use this package alongside
baseUrl
, I think I'm holding it wrong lol.So I upgraded AVA to
ava@next
(4.0.0-rc.1
) and installed the latest@ava/typescript
(3.0.1
). My project uses TypeScript Project References, and dumps files into a.build-tsc/
directory, so I setcompile: false
, and edited my test script to compile before runningava
.Project has a
src/
directory at the root containing code, and atests/
directory containing a mix of tests (file extension*.test.tsx?
) and utilities for tests (just ending in.ts
). I setbaseUrl
in mytsconfig
to the package root, and before trying@ava/typescript
, I was just settingNODE_PATH
to.build-tsc
so that Node could find all the proper files.That's fine, but the main downsides are A) all the errors are in the compiled JS instead of the TS, making it harder to understand where the errors come from; and B) pretty sure it just doesn't work with JSX at the moment (but that's less pressing since I'm mostly testing backend business logic).
So trying out
@ava/typescript
, I set my config as follows:This evidently is not correct, as I get errors like the following whenever a test tries to import anything in
src
:And then if I set
NODE_PATH
again to.build-tsc
, then it works, but once again it's no different in that error line numbers are in the original JS files, not the TS ones.So yeah I'm not totally sure how to A) make TypeScript
baseUrl
(and relatedlypaths
which I'm not using right now) work, and B) how I should be doing things to get the line numbers to be those of the TypeScript files. I think some more detailed examples/documentation for these kinds of use cases, or at least a disclaimer that this isn't supported, would be helpful for me!