-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Mocking scoped package libraries #4262
Comments
FYI related: cognitedata#5 |
Try using jest CLI for "test" in package.json: |
@bugzpodder using your method is there a way to map a scope (say For example I have a package
Do you know if I have to point to a concrete file for each reference e.g. or is there a way to do something like this:
|
I am not too familiar with this jest feature, I would look at their docs. But essentially you can pass in CLI flags for jest this way through package.json |
** Workaround ** I've just done some reading and managed to get it working. You can back reference the regex groups using and map it by matching the directory structure of any package under that scope:
I can use these mocks like I think being able to define this in the package.json would still be a nice feature, but you can provide escaped json to your npm test command. |
I am running into the same situation, trying to migrate an app from create-react-app-ts to create-react-app. The original app uses It appears that CRA is using |
I have created PR #6633 to support merging of external |
I dont know why, but i solved such problem with moduleNameMapper pulling it out of the package.json and putting into jest.config.js, now my jest omits scss files as should |
@LeksorHayabusa, I tried your workaround. It is not working for me. I think the reason Jest omits scss files for you is because the internal Jest configuration asks it to do so. |
I was trying to run the Jest test suite in my local environment! I created a jest.config.js in the root directory of my project and moved the configs of Jest from package.json to jest.config.js also while running tests through cmd |
Already fixed by #6055. |
I've been working on migrating a project which we ejected some time ago back into CRA.
I've come across a problem with the way we are mocking scoped packages. We were using the
moduleNameMapper
in the jest section of our package.json like this:package.json
When I add this to the un-ejected CRA project I get the following error:
Any ideas how I can get these mocks working?
The text was updated successfully, but these errors were encountered: