DEV Community


Discussion on: Path aliases with TypeScript in Node.js

ksnyde profile image
Ken Snyder • Edited

These aliases -- which I've grown used to on the frontend frameworks which use webpack -- are a VERY welcome addition to writing typescript on the backend (or in other library code). My one question comes down to testing. I have a library with hundreds of tests but right now none of them run because I'm using Mocha/Chai with ts-node and I'm not sure but I think that ts-node is not able to use the alias.

The command I use is:

./node_modules/.bin/mocha --no-timeouts --require ts-node/register --exit

This is a pretty standard way of testing as it allows you to test directly on the source rather than needing to transpile before testing.