Hello! We are using <jest-pact> adapter library fo...
# pact-js
m
Hello! We are using jest-pact adapter library for writing our contract tests and want to rewrite one of them to pact-js. But, after updating package
pact-foundation/pact
to version
"^10.1.3"
, - all our tests (that are written on jest-pact library) failed with Axios Network Error and following stack trace. So, even if I want to rewrite one of them on pact-js library, errors never go away. So, tell me please, what is going wrong?
Copy code
Network Error

      at createError (node_modules/axios/lib/core/createError.js:16:15)
      at XMLHttpRequest.handleError (node_modules/axios/lib/adapters/xhr.js:117:14)
      at XMLHttpRequest.invokeTheCallbackFunction (node_modules/jsdom/lib/jsdom/living/generated/EventHandlerNonNull.js:18:28)
      at XMLHttpRequest.<anonymous> (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:338:25)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3)
      at XMLHttpRequestImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:221: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 dispatchError (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:60:3)
      at validCORSHeaders (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:75:5)
      at validCORSPreflightHeaders (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:89:8)
      at Request.<anonymous> (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:374:12)
      at Request._processResponse (node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:228:12)
      at ClientRequest.<anonymous> (node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:101:12)
Interesting, after a downgrade to 10.1.2, an error seems more informative
Copy code
console.error
      Error: Cross origin <http://localhost> forbidden
          at dispatchError (C:\...\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:63:19)
          at validCORSHeaders (C:\...\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:75:5)
          at validCORSPreflightHeaders (C:\...\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:89:8)
          at Request.<anonymous> (C:\...\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:374:12)
          at Request.emit (node:events:390:28)
          at Request._processResponse (C:\...\node_modules\jsdom\lib\jsdom\living\helpers\http-request.js:228:12)
          at ClientRequest.<anonymous> (C:\...\node_modules\jsdom\lib\jsdom\living\helpers\http-request.js:101:12)
          at Object.onceWrapper (node:events:510:26)
          at ClientRequest.emit (node:events:390:28)
          at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:623:27) undefined

      at VirtualConsole.<anonymous> (node_modules/jsdom/lib/jsdom/virtual-console.js:29:45)
      at dispatchError (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:66:53)
      at validCORSHeaders (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:75:5)
      at validCORSPreflightHeaders (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:89:8)
      at Request.<anonymous> (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:374:12)
      at Request._processResponse (node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:228:12)
It seems like breaking changes that have been on upgrading from version 9.18.1 to 10.0.0 and upper
It seems like that is already a known issue
t
Thanks for flagging this. I put a note on the issue that points at the problem.
m
Thank you, Timothy!
m
Hey folks sorry I'm late to the party, I'm out at a conference. Looks like there is a bug with the cors options passing and/or core behaviour. We'll dig into this next week when I'm back.
👌 1