-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Bug]: Unable to mock axios module if imported from monorepo package #14376
Comments
Reproduction does not work. After running ERR! bootstrap The "bootstrap" command was removed by default in v7, and is no longer maintained.
ERR! bootstrap Learn more about this change at https://lerna.js.org/docs/legacy-package-management |
@mrazauskas Updated UpdatedClone my repo - https://github.com/doublehrajput/jest-axios-mock-bug_report.git |
Nothing much new.
lerna notice cli v7.1.4
lerna ERR! Lerna has already been initialized for this repo.
lerna ERR! If you are looking to ensure that your config is up to date with the latest and greatest, run `lerna repair` instead
ERR! bootstrap The "bootstrap" command was removed by default in v7, and is no longer maintained.
ERR! bootstrap Learn more about this change at https://lerna.js.org/docs/legacy-package-management |
@mrazauskas Remove all files and do a fresh clone and try again |
For me it seems that your problems can be caused by legacy software. Some might be installed globally and that is why The link in the error message is very good starting point to understand why you should consider upgrading the setup of your repo. Simply put: you don’t need EDIT Probably everything is fine with the old version of Lerna. All I try to say is that you don’t need |
@mrazauskas you are right.. Sorry for that Updated steps .Clone my repo - https://github.com/doublehrajput/jest-axios-mock-bug_report.git I hope you won't get error while installing packages now please take latest pull of my code |
Why to use Why to use |
yes in v7 , but my project has lerna setup .. I have to stick with it.. |
Also I have removed lerna https://github.com/doublehrajput/jest-axios-mock-bug_report/tree/removed-lerna now I am getting error for monorepo package axios while working fine for local package instance |
I think the problem is that you have two instances of
Calling Not sure how to make this work. I think for unit testing you should mock |
It is just a poc, there are multiple axios call inside design-system. Using msw I am able to intercept all request call, which is working fine. But I don't want to use it... |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
29.6.2
Steps to reproduce
npx lerna init
npx lerna bootstrap
npx lerna run build --scope=design-system
-- this will create build of design systemyarn jest --watchAll
Expected behavior
Should able to mock axios which is imported through "design-system"
Actual behavior
Getting error -- seems like axios is not mocked when imported in monorepo
{
response: AxiosError {
hostname: 'urltotest.com',
syscall: 'getaddrinfo',
code: 'ENOTFOUND',
errno: -3008,
message: 'getaddrinfo ENOTFOUND urltotest.com',
name: 'Error',
config: {
transitional: [Object],
adapter: [Array],
transformRequest: [Array],
transformResponse: [Array],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: [Object],
validateStatus: [Function: validateStatus],
headers: [AxiosHeaders],
method: 'post',
url: 'http://urltotest.com',
data: undefined
},
............................
Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: