pact-foundation / jest-pact

A Pact adaptor for to allow you to easily run tests with Jest
https://pact.io
MIT License
81 stars 12 forks source link

future proofing `jest-pact` / `jasmine is undefined` #197

Closed outcomes-timothy-huddle closed 4 years ago

outcomes-timothy-huddle commented 4 years ago

jest provides a function that you can use per test file to override the test timeout. It works across all test-runners, which is important, since right now jest-pact only works if you're using the jasmine runner.

In jest@26 they've added a new runner, jest-circus, and in react-scripts@4 that is the default testRunner, so jasmine is no longer a thing. In jest@27 jest-circus will be the default for jest period, and in jest@28 you'll have to explicitly install the jasmine runner yourself to be able to use it.

I am aware that currently jest-pact specifies a peer dependency of a very small subset of jests, but react-scripts@4 is coming, and it's bringing jest@26 & jest-circus with it.

package versions:

jest-pact: 0.7.0 @pact-foundation/pact: 9.11.1 jest: 26.4.0 (yes, I am aware this is outside the defined peerDependency range)

repro:

clone https://github.com/cah-timhuddle/jest-pact-bug-repro install the dependencies and run npm test you'll be able to see the jasmine is undefined

TimothyJones commented 4 years ago

Good eye. Thank you for bringing this up, and for such a detailed report!

PRs are welcome if you'd like to contribute, otherwise I'll have some pact time in about a week.

TimothyJones commented 4 years ago

Thanks so much for this! After a false start, I've released 0.8.1, which works with your repro repo:

 PASS  src/test.js
  Pact between test-consumer and test-provider
    with 30000 ms timeout for Pact
      it doesnt work with test runners other than jasmine
        ✓ should work (21 ms)