testing-library / jest-dom

:owl: Custom jest matchers to test the state of the DOM
https://testing-library.com/docs/ecosystem-jest-dom
MIT License
4.45k stars 401 forks source link

I am using Signalr in react and writing unit test, but test cases fails where signalr used #543

Closed muhammadali-HazelSoft closed 1 year ago

muhammadali-HazelSoft commented 1 year ago

TypeError: Cannot read properties of undefined (reading 'availableTransports')

at Object.availableTransports [as success] (node_modules/signalr/jquery.signalR.js:733:33) at apply (node_modules/jquery/dist/jquery.js:3223:31) at Object.fire [as resolveWith] (node_modules/jquery/dist/jquery.js:3353:7) at resolveWith (node_modules/jquery/dist/jquery.js:9627:14) at XMLHttpRequest.complete (node_modules/jquery/dist/jquery.js:9880:10) at XMLHttpRequest.invokeTheCallbackFunction (node_modules/jsdom/lib/jsdom/living/generated/EventHandlerNonNull.js:14:28) at XMLHttpRequest. (node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:35:32) at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25) at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3) at XMLHttpRequestImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9) at fireAnEvent (node_modules/jsdom/lib/jsdom/living/helpers/events.js:18:36) at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:131:3) at Object.dispatchError (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:60:3) at Request. (node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18) at NodeClientRequest. (node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:121:14) at NodeClientRequest.Object..NodeClientRequest.emit (node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/NodeClientRequest.ts:299:22)

gnapse commented 1 year ago

This seems more appropriate right now for being a question in a help forum, rather than an issue with jest-dom. At the very least, I'd expect a minimal reproducing sample (e.g. a small repo with a react component and a test that fails, so others could reproduce). I do not even know what Signalr is, and for all we know, this could be an issue caused by either Signalr, the combination of it with jest-dom, or even an issue caused by your own code when using both. Don't know.

My suggestion: post this in the repo discussions, or in StackOverflow. And wherever you end up posting it, add more details.

If the results from that show that jest-dom is at fault or could do something better to support your use case, then come back with those details and actionable things to do on our end.

Thanks!