For example, instead of using babel-register, I may want to import the pre-transpiled modules instead. The only problem is I would have to do ../../../../../lib/MyModule.js, which isn't pretty or easy to maintain.
Here's a good solution:
const {redirectImports} = require('testpass')
// The given function is called for every `require` call from a test file.
redirectImports((filename, parent) => {
return filename.replace('/src/', '/lib/')
})
For example, instead of using
babel-register
, I may want to import the pre-transpiled modules instead. The only problem is I would have to do../../../../../lib/MyModule.js
, which isn't pretty or easy to maintain.Here's a good solution:
You would call
redirectImports
beforefindTests
.