Skip to content

Possible to disable jsdom for some test suites? #1467

Closed
@johanventer

Description

@johanventer

I'm working on an app that uses Amazon's API Gateway, the JS SDK uses axios under the hood. The tests that call a service fail with the following when using jsdom:

Network Error      
      at createError (node_modules/axios/lib/core/createError.js:15:15)
      at XMLHttpRequest.handleError [as onerror] (node_modules/axios/lib/adapters/xhr.js:87:14)
      at XMLHttpRequest.callback.(anonymous function) (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:289:32)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)
      at invokeInlineListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:166:7)
      at EventTargetImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:122:7)
      at EventTargetImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
      at XMLHttpRequest.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)
      at dispatchError (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:946:9)
      at validCORSHeaders (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:979:7)
      at receiveResponse (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:834:12)
      at EventEmitter.client.on.res (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:662:38)
      at emitOne (events.js:96:13)
      at EventEmitter.emit (events.js:188:7)
      at Request.realClient.on.res (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:281:49)
      at emitOne (events.js:96:13)
      at Request.emit (events.js:188:7)
      at Request.onRequestResponse (node_modules/request/request.js:986:10)
      at emitOne (events.js:96:13)
      at ClientRequest.emit (events.js:188:7)
      at HTTPParser.parserOnIncomingClient (_http_client.js:474:21)
      at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
      at TLSSocket.socketOnData (_http_client.js:363:20)
      at emitOne (events.js:96:13)
      at TLSSocket.emit (events.js:188:7)
      at readableAddChunk (_stream_readable.js:176:18)
      at TLSSocket.Readable.push (_stream_readable.js:134:10)
      at TLSWrap.onread (net.js:548:20)

If I disable jsdom (by removing --env=jsdom from package.json) then these tests succeed. However, this then makes tests using ReactDOM.render fail.

Can I have my cake and eat it to? Perhaps some way to disable jsdom in particular test suites and reset the environment?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions