Replies: 1 comment
-
Hi @korulis ! Have you succeed to solve your problem ? Going through the same issue rn |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is a port of a question from @ava/typescript forum as suggested by the author of that package - novemberborn.
I am trying to create a Typescript project with Ava testing where I could debug the code while tests are running. My setup used to just work (as described here) when I was using
commonjs
modules, but after switching toesm
I can not get it to work. I have spent hours and days looking for the right configuration and/or workaround for that.This is my current setup (master branch on repo) after switching to
esm
modules.Adding breakpoints and running the app
yarn start
correctly stops at breakpoints, but when runningyarn test
it does not stop at breakpoints.I was expecting the execution to stop at breakpoints in
app.ts
andtest.test.ts
filesWhat Iv'e tried so far:
esm-module-alias
to create custom loader. This fixes the issue of alias paths in generated.js
files, and allows debugging in vscode both with"start": "rm -rf dist && NODE_ENV=development tsx watch ./src/app/index.ts",
and"build_and_start_ema": "tsc && node --loader=./dist/app/alias.js ./dist/app/index.js",
commands. It also allows running ava tests with"test": "NODE_OPTIONS='--import=tsx' ava --config unittest.js",
,but does not allow debuging. (on master branch)tsconfig-paths
to fix aliased import paths in generated javascript - this does not even allow running the app after build phase. (on master branch)ts-patch
to fix aliased import paths in generated javascript - this does not allow running tests at all. See repo branch."build_tsca": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json",
, which means I can not run tests continuously usingyarn test --watch
. See repo branch.tsc
to compile/transpile my typescript into javascript intodist/
folder and then runing with ava without the typescript config (yarn build
+yarn test
). See commit for this attempt. This does run the tests, but it still does not stop at vscode breakpoints. Why I expected the breakpoints to work in this case? After all, my breakpoints are in.ts
files and I am executing strictly only.js
files indist/
folder... - because when I do analogous thing for running the app"build_and_start_ema": "tsc && node --loader=./dist/app/alias.js ./dist/app/index.js",
it DOES hit the breakpoints in.ts
files even though I am executing only the.js
files.Overall my best attempts were attempt 1 and 4, but attempt 1 is better because it allows running tests continuously.
How can I achieve being able to continously run and debug ava tests in vscode on a typescript project with ESM modules that uses aliased import paths, like it used to when I was using
commonjs
modules?my "flattened" tsconfig in master branch:
How can I achieve being able to continously run and debug ava tests in vscode on a typescript project with ESM modules that uses aliased import paths, like it used to when I was using commonjs modules?
Beta Was this translation helpful? Give feedback.
All reactions