pactflow / pact-msw-adapter

Create MSW (mock-service-worker) mocks, and generate pact contracts from the recorded interactions.
MIT License
44 stars 15 forks source link

Cannot find module './pact/frontendwebsite-productservice.json' #21

Closed christemple closed 2 years ago

christemple commented 2 years ago

Hi,

I'm new to Pact contract testing, but not to MSW, and I'm keen to let MSW be the MockServer to create the pacts in my tests, hence why I'm trying out your package 🙂

However whenever I install the package and use your example from the README I get the following error:

 Cannot find module './pact/frontendwebsite-productservice.json' from 'node_modules/msw-pact/lib/setupMswFromPact.js'

    Require stack:
      node_modules/msw-pact/lib/setupMswFromPact.js
      node_modules/msw-pact/lib/mswPact.js
      contract.test.js

The only changes I've made from your example are is changing this to:

import { setupMswPact } from 'msw-pact';

I can see where this will work when running the tests in your repo, but the published package doesn't include the json file. I might be wrong but I suspect the json file isn't needed for the published package anyway? It looks like it's an example scenario set up for the tests in this repo?

I will have to switch back to using Pact's mockserver to finish my work, but very keen to see this solution grow so I can leverage the MSW we already have.

Let me know if you'd like some help fixing this :+1:

YOU54F commented 2 years ago

Hello @christemple, you are indeed correct, that is my fault in publishing that file.

Help is always appreciated, and I applore your excellent issue. Sorry this slipped the net.

I am just about to push up a version 0.7.0 with some changes in it, which should resolve this and also change the interface slightly. Would love to get some feedback, as we are looking to get this into proper use, and I've not yet used MSW on a proper project, so having people with a real use case, to help shape it's development is welcomed :)

YOU54F commented 2 years ago

Please see version 0.8.1 Thanks @christemple