rewiremock
rewiremock copied to clipboard
Typescript setup Error: Rewiremock: there is no "parent module". Is there two HotModuleReplacementPlugins?
I'm trying to use rewiremock
after converting from using rewire
in a typescript project.
// ./rewiremock.ts
import rewiremock, {addPlugin, plugins} from 'rewiremock'
rewiremock.overrideEntryPoint(module) // this is important. This command is "transfering" this module parent to rewiremock
addPlugin(plugins.nodejs)
// we need webpack aliases
addPlugin(plugins.webpackAlias)
// and all stub names would be a relative
addPlugin(plugins.relative)
// and all stubs should be used. Lets make it default!
addPlugin(plugins.usedByDefault)
export { rewiremock }
// ./test/demo.test.ts
import { rewiremock } from '../rewiremock'
Even just importing is enough for the error to occur.
This has the same error as https://github.com/theKashey/rewiremock/issues/137 but a different environment and setup.