Closed BlackoutGG closed 4 years ago
Hi @BlackoutGG !
Yes that's a know issue ; jest
completely overrides the normal import behavior, so module-alias can't do much. However jest has it's own way of defining aliases. That's documented in our README ; we point to Jest docs . I'm afraid you'll have to copy your aliases over into you Jest confing.
Technically you could use a config.js
file that would dynamically read your module-alias config from package.json
, but unless you maintain a bajillion aliases that's probably not worth it.
Will close the issue.
PS: Your issue made me realize our link was out of date, thanks ^^
Use case: I'm trying to test endpoints with jest and super test against an express api backend. My problem being I'm using module-alias to make my requires() a little more sane. Works fine when running it normally, however seen as I throw jest into the mix that's where everything goes pear shaped. From what I read module-alias doesn't work inside dependencies, so I guess it won't resolve within a test being executed by jest.
Here's the error I get: ` Test suite failed to run
Outside of tests everything works fine.