pact-example-jest

2.0.1 • Public • Published

Jest Example

  1. In the pact-js project root, change to the examples/jest directory
  2. Run: npm i
  3. Run the tests: npm t

Comments about Jest

You will need to run jest 'in band' as it will cause state issues otherwise. If you are running a large unit test suite you'll probably want to run that separately as a result to take advantage of the concurrency of jest (it is quite a slow down). To achieve this you can get your pact tests to have a suffix of '.pact.js' and add the following to your pact task in npm:

--testRegex \"/*(.test.pact.js)\""

Also the examples have set up a global 'provider' variable using the 'pactSetup.js' file. Then the pactTestWrapper.js ensures each test file will have the provider setup for them. The beforeAll and afterAll in jest is not before all tests but before each file. I had to put the

pactfileWriteMode: 'update'

in the provider to get pacts appended to.

Also note the publish is a separate task. As there is no real afterAll it is difficult to know when to publish in normal running so I had to extract it.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.15latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.15
2.0.00
1.0.20
1.0.10

Package Sidebar

Install

npm i pact-example-jest

Weekly Downloads

0

Version

2.0.1

License

MIT

Unpacked Size

252 kB

Total Files

21

Last publish

Collaborators

  • aryasadeghy