-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
'mockImplementation' and 'mockResolvedValue' are not functions when mock 'axios' #5993
Comments
@@ -5,12 +5,11 @@ import Educations from '../components/Educations/index';
import { URL_PATH_EDUCATIONS } from '../constants/index'
import { shallow, render, mount } from 'enzyme';
+jest.mock('axios');
describe('WithFetching', () => {
const WithFetching = withFetching(URL_PATH_EDUCATIONS, Educations); // withFetching is HOC
- jest.mock('axios');
-
it('should fetch educations', () => {
const resp = { data: [{ name: 'FooBar' }]};
axios.get.mockImplementation(() => Promise.resolve(resp)); Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions. |
Thanks! I just haven't found that we have to keep |
PR welcome to update/clarify docs 🙂 |
I am having the same issue and my jest.mock('axios'); is in scope with import.
I am using the CRA package.json with the react-scripts. I am getting the error: |
See #6832 |
same problem here on Vue |
* Added support for streamable embeds * Reverting mistaken README changes * Removing last line inserted by prettier ... * Fixing up Twitter section ... * Updating to use HTML embed code from Streamable API * fixing linting * Fixing last of validation errors * Update README.md Co-Authored-By: Michaël De Boey <info@michaeldeboey.be> * Updating PR in response to code review feedback * Fixing single quote issue and updating readme * Renaming test, alphabetized kitchen sink test * Extracted mockFetch, though there is a dependency on jest usage that requires the mocking of node-fetch to occur in each test file (jestjs/jest#5993), updated tests * undo mock fetch extraction and inline expected html result * Apply suggestions from code review Co-Authored-By: Michaël De Boey <info@michaeldeboey.be> * Using URL dependency, removed extra bit from Readme * Adding test coverage for more verbose logic * Simplified shouldTransform function * Update tests * Update docs * Updating shouldTransform * Further updates to shouldTransform method * Updating to simply use array.includes * Added suggested changes * Added getNormalizedStreamableUrl function * Fixing normalized streamable URL * fix linting rule * fix * Extract normalized var * Cleanup code * Cleanup tests * Add Streamable to package.json keywords * Update iframe test Co-authored-by: Michaël De Boey <info@michaeldeboey.be>
* Added support for streamable embeds * Reverting mistaken README changes * Removing last line inserted by prettier ... * Fixing up Twitter section ... * Updating to use HTML embed code from Streamable API * fixing linting * Fixing last of validation errors * Update README.md Co-Authored-By: Michaël De Boey <info@michaeldeboey.be> * Updating PR in response to code review feedback * Fixing single quote issue and updating readme * Renaming test, alphabetized kitchen sink test * Extracted mockFetch, though there is a dependency on jest usage that requires the mocking of node-fetch to occur in each test file (jestjs/jest#5993), updated tests * undo mock fetch extraction and inline expected html result * Apply suggestions from code review Co-Authored-By: Michaël De Boey <info@michaeldeboey.be> * Using URL dependency, removed extra bit from Readme * Adding test coverage for more verbose logic * Simplified shouldTransform function * Update tests * Update docs * Updating shouldTransform * Further updates to shouldTransform method * Updating to simply use array.includes * Added suggested changes * Added getNormalizedStreamableUrl function * Fixing normalized streamable URL * fix linting rule * fix * Extract normalized var * Cleanup code * Cleanup tests * Add Streamable to package.json keywords * Update iframe test Co-authored-by: Michaël De Boey <info@michaeldeboey.be>
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. |
Do you want to request a feature or report a bug?
Probably a bug
What is the current behavior?
When I try to mock axios as in docs and run my test it's failed:
And it shows me the error:
TypeError: _axios2.default.get.mockImplementation is not a function
The same happens with
axios.get.**mockResolvedValue**(resp);
What is the expected behavior?
No error is presented and mockResolvedValue(resp), mockImplementation are functions and work as described in docs
Please provide your exact Jest configuration
From my package.json
jestsetup.js:
Enviroment:
I already saw the Issue#5962 and I am not sure but they are maybe connected somehow
The text was updated successfully, but these errors were encountered: