Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ertrzyiks/pact-js-interactions-order
https://github.com/ertrzyiks/pact-js-interactions-order
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ertrzyiks/pact-js-interactions-order
- Owner: ertrzyiks
- License: mit
- Created: 2020-11-13T07:35:19.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-13T07:58:38.000Z (about 4 years ago)
- Last Synced: 2024-12-07T19:36:03.985Z (about 2 months ago)
- Language: JavaScript
- Size: 510 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pact-js-interactions-order
This is an example project using `@pact-foundation/pact` and `pact-jest` to run consumer pact tests.
## Problem
When a project uses multiple files with pact interactions and runs them with `jest` the content of the contract file
may change even the consumer tests did not. It's caused by undeterministic order of loading test files.To spread interactions across files we need to use:
```
pactfileWriteMode: 'merge'
```
and then each spec file adds it's interactions to the contract file in the same order that spec files are executed.## Example
Compare `./consumer-provider.run1.json` with `./consumer-provider.run2.json` to see what changes inside the contract file.
![](./screenshot.png)
## Steps to reproduce the problem
1. Install all dependencies
```bash
yarn
```2. Run the consumer pact tests
```bash
yarn test
```3. Run the consumer pact test again and again. See that the `pact/pacts/consumer-provider.json` includes the same
interactions but in undeterministic order.