Using jest-preset-angular with Pact for Contract Testing
See original GitHub issueHello I’m trying to configure a Consumer based contract test using Pact library which requires Jest to run in a Node test environment.
Receiving this error when I try to run my test.
ReferenceError: XMLHttpRequest is not defined
I see that jest-preset-angular brings in zone.js which is trying to pull in xhr.
Any way around this? Thank you for your time.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
How to set up Pact tests with Angular & Jest | by Dany Marques
Let's first create an Angular service using Angular schematics. This will create a user service under core folder. ... You're now able to...
Read more >API contract testing with Pact and Angular - Stack Overflow
I can't quite see what's happening with the proxy, but it doesn't seem to align with what your code actually does (the proxy...
Read more >jest-pact - npm
Start using jest-pact in your project by running `npm i jest-pact`. There is 1 other project in the npm registry using jest-pact.
Read more >Consumer Driven Contract Testing with Pact - Blog - RisingStack
To test the contract, we need to set up the pact verifier first. We'll be using [pact-node](https://github.com/pact-foundation/pact-node) for ...
Read more >Introduction To Pact Contract Testing With Examples
Contract tests fit nicely within a microservice architecture, operating in an agile setting. Therefore examples will be based on the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@39ro actually we override
testEnvironment
when you loadjest-preset-angular
to use the latest jsdom as test environment: https://github.com/thymikee/jest-preset-angular/blob/c05c122ec4e364d3a59b8524478b9425feadd059/jest-preset.js#L15Anyway the
XMLHttpRequest
error is usually related to the preset not being loaded properly orglobal.ts-jest
options overwritten in a wrong way, not as described in the README.md. If the ts-jest ast transformers are loaded properly,XMLHttpRequest
s are not required anymore.Close as inactivity