Open hualu00 opened 6 years ago
Did you also add the function to transformFunctions
?
Shouldn't your code be like this?
const resolvePath = c => c
const ProxyInboxModel = proxyquire('../model.js', {
[ resolvePath('../model.js')]: {
...
}
}).default
I'm not familiar with proxyquire
, so I'm just trying to find the error with you :)
seeing this in a project I inherited and am fixing up - moving the test to the same level as the file fixed it - not ideal, but works
Bellowing is my original code sample:
It didn't work as 'messages' is not resolved by module-resolver, after reading this great explanation,
https://github.com/tleunen/babel-plugin-module-resolver/blob/master/DOCS.md#usage-with-proxyquire
I've changed my code to this:
This time 'messages' was resolved, but with the wrong path. And the root cause is I use proxyquire in a test file, and this test file is not at the same folder with its test-ee.
Let's say
'a/b/c.js' and 'a/b/test/c-test.js'
in 'a/b/c.js', 'messages' is resolved as '../../path/messages',
but in 'a/b/test/c-test.js' , it is '../../../path/messages'