New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storybook integration not working #82
Comments
So there is multiple issues here:
import './lib';
import './ComponentExample';
const ComponentExample = rewiremock.proxy(() => require("./ComponentExample"), () => {
rewiremock(() => require("./lib")).with({
COUNT: 100
});
}).default; In the same time :) there are two bugs in rewiremock which will not allow you to do it. Give me a few hours to fix them. [ ] - main chunk has no name and causing |
Yep. But Switch to just |
I changed the webpack import to default import and it worked!
So is there something to still fix? |
You know - I don't know. These bugs existed just after fresh install, but later I could not reproduce them. They were related to a chunk 0 being 0, and I have to idea what it was - all chunks are named, or/and starts from 1. |
maybe deleting node modules and yarn lock. I didn't get those |
I've been using this, and works just fine. It even replace the modules in nested components This is the code for future reference import React from "react";
import rewiremock from "rewiremock";
import { storiesOf } from "@storybook/react";
import { datbaseMock, serviceMock } from './mocks';
const ModifiedProfile = rewiremock.proxy(
() => require("./Profile"),
() => {
rewiremock(() => require("./service")).with(serviceMock);
rewiremock(() => require("./database")).with(databaseMock);
}
).default;
storiesOf("Profile View", module).add("default state", () => <ModifiedProfile />); When you do this, you lose hot reloading, but I believe this will happen with any mocking library. I think is safe to close this now |
I’ll double check hot loading ;) |
Hi,
I'm trying to use rewiremock inside my storybook with react project, but is not working.
I only get a error in the console, but not a useful one.
I tried in a clean environment with a fresh installs and the error still persists
Clean Reproduction Repo: https://github.com/saintplay/rewiremock-storybook-bug
I didn't forget to add the three plugins required, and the babel plugin.
Steps to Reproduce
Hope you can help to solve this use case, thanks
UPDATE
After some tweaking I managed to get this working. Example code here
The text was updated successfully, but these errors were encountered: