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

Typescript Compiler failing with error TS2307 #200

Closed sjiwani-skillz closed 3 years ago

sjiwani-skillz commented 3 years ago

The following error is thrown when running tsc in my project:

node_modules/jest-pact/dist/types.d.ts:2:53 - error TS2307: Cannot find module '@pact-foundation/pact/dsl/options' or its corresponding type declarations.

2 import { MessageConsumerOptions, PactOptions } from '@pact-foundation/pact/dsl/options';

The issue seems to be stemming from this line: https://github.com/pact-foundation/jest-pact/blob/dc23a09f02d40a15c3f2b0812f0b1bc0e77bf830/src/types.ts#L5

If I change the import to be import { MessageConsumerOptions, PactOptions } from '@pact-foundation/pact'; or import { MessageConsumerOptions, PactOptions } from '@pact-foundation/pact/src/dsl/options'; it works.

@pact-foundation/pact - version : 9.15.5 jest-pact - version: 0.8.3

TimothyJones commented 3 years ago

Ah, thank you! That’s definitely a mistake. I’ll get it fixed up.

TimothyJones commented 3 years ago

This is fixed in jest-pact v0.9.0, releasing shortly.

I had to increase the peer dependency for pact to 9.12.2 (although that won't affect anyone experiencing this issue, because it only happens from 9.15.0 onwards, it might affect others who haven't experienced this issue yet).

Thanks for the report!