'TypeScript testing -- access to static assets?

I have a CLI application written in TypeScript. It builds, using tsc, transpiling to JS in a build directory. I have tests to test the code involved in the CLI app. Those tests require access to static assets. TSC transpiles my TypeScript code to JS, and puts it in the build directory.

Once it's in that build directory, I can't figure out how to give the code access to the static assets needed for testing. Obviously, relative paths based on the TS files don't do me much good. __dirname resolves to the directory of the compiled JS files, and not the directory of the original TS files, so that doesn't help.

I don't want to do something that makes no sense pre-transpilation (but works post-transpilation), but I can't figure out a way for this asset access to make sense in both situations. I can't be the first person to run into this. Is there some magic token I should know about?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source