Vite allows to import files as raw strings using
import foo from "foo.txt?raw"
However, jest complains that it cannot find the file. I found the jest-raw-loader, but I don't know how to tell it to apply raw loading to the "?raw" syntax.
I added the following to moduleNameMapper
it worked.
"moduleNameMapper": {
".*\\.txt\\?raw": "jest-raw-loader"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With