Skip to content
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

fetch-mock: No fallback response defined for GET to https://jsonmock.hackerrank.com/api/stocks/?date=1-January-2002 #632

Open
garg10may opened this issue Mar 13, 2022 · 0 comments

Comments

@garg10may
Copy link

garg10may commented Mar 13, 2022

CodeSandbox: https://codesandbox.io/s/quizzical-carlos-k5i4en?file=/src/App.test.js
Stackoverflow: https://stackoverflow.com/questions/71455887/react-fetch-mock-no-fallback-response-defined-for-get

Not able to figure out the below error message. It fails on the three test cases written by hackerrank team so I am assuming they are supposed to be passed. At least they must have tested their test cases. I tested for different versions, 7.0.0, 7.3.1, 9.0.0-beta.2. It's still failing

Test Case: Search is made on by clicking on search button and no results found

fetch-mock: No fallback response defined for GET to https://jsonmock.hackerrank.com/api/stocks/?date=1-January-2002

  14 |   const fetchData = () => {
  15 |     const Url = 'https://jsonmock.hackerrank.com/api/stocks/?date=' + date;
> 16 |     fetch(Url)
     |     ^
  17 |       .then(res => res.json())
  18 |       .then((result) => {
  19 |         if (result.data[0]) {

  at Object.<anonymous>.FetchMock.executeRouter (node_modules/fetch-mock/src/lib/fetch-handler.js:106:9)
  at Object.fetch [as fetchHandler] (node_modules/fetch-mock/src/lib/fetch-handler.js:56:21)
  at fetchData (src/components/stock-data/index.js:16:5)
  at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:188:14)
  at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:237:16)
  at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:292:31)
  at invokeGuardedCallbackAndCatchFirstError (node_modules/react-dom/cjs/react-dom.development.js:306:25)
  at executeDispatch (node_modules/react-dom/cjs/react-dom.development.js:389:3)
  at executeDispatchesInOrder (node_modules/react-dom/cjs/react-dom.development.js:414:5)
  at executeDispatchesAndRelease (node_modules/react-dom/cjs/react-dom.development.js:3278:5)
  at executeDispatchesAndReleaseTopLevel (node_modules/react-dom/cjs/react-dom.development.js:3287:10)
  at forEachAccumulated (node_modules/react-dom/cjs/react-dom.development.js:3259:8)
  at runEventsInBatch (node_modules/react-dom/cjs/react-dom.development.js:3304:3)
  at runExtractedPluginEventsInBatch (node_modules/react-dom/cjs/react-dom.development.js:3514:3)
  at handleTopLevel (node_modules/react-dom/cjs/react-dom.development.js:3558:5)
  at batchedEventUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:21871:12)
  at batchedEventUpdates (node_modules/react-dom/cjs/react-dom.development.js:795:12)
  at dispatchEventForLegacyPluginEventSystem (node_modules/react-dom/cjs/react-dom.development.js:3568:5)
  at attemptToDispatchEvent (node_modules/react-dom/cjs/react-dom.development.js:4267:5)
  at dispatchEvent (node_modules/react-dom/cjs/react-dom.development.js:4189:19)
  at unstable_runWithPriority (node_modules/scheduler/cjs/scheduler.development.js:653:12)
  at runWithPriority$1 (node_modules/react-dom/cjs/react-dom.development.js:11039:10)
  at discreteUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:21887:12)
  at discreteUpdates (node_modules/react-dom/cjs/react-dom.development.js:806:12)
  at dispatchDiscreteEvent (node_modules/react-dom/cjs/react-dom.development.js:4168:3)
  at node_modules/@testing-library/dom/dist/events.js:25:20
  at node_modules/@testing-library/react/dist/pure.js:65:16
  at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:21856:12)
  at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:929:14)
  at Object.eventWrapper (node_modules/@testing-library/react/dist/pure.js:64:28)
  at fireEvent (node_modules/@testing-library/dom/dist/events.js:16:35)
  at Function.fireEvent.<computed> [as click] (node_modules/@testing-library/dom/dist/events.js:124:36)
  at Function.click (node_modules/@testing-library/react/dist/fire-event.js:18:52)
  at Object.<anonymous> (src/App.test.js:32:13)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant