https://pact.io logo
Join Slack
Powered by
# pact-msw-adapter
  • j

    Joel Whalen

    10/11/2023, 7:41 PM
    Trying to run these commands locally, getting this error
    Copy code
    ➜  pact-msw-adapter git:(main) yarn run example:link 
    yarn run v1.22.19
    $ cd examples/react && yarn link @pactflow/pact-msw-adapter
    warning package.json: No license field
    error No registered package found called "@pactflow/pact-msw-adapter".
    • 1
    • 2
  • j

    Joel Whalen

    10/11/2023, 8:27 PM
    Has anyone ran the unit tests successfully with the vscode debugger? I'm seeing "debugger attached" messages in the console, and the tests are running successfully, but the program is not stopping at the breakpoints I'm setting. @Yousaf Nabi (pactflow.io) could you share your
    .vscode/launch.json
    if you've gotten this to work?
    🤔 1
    y
    • 2
    • 2
  • j

    Joel Whalen

    10/13/2023, 3:19 PM
    You guys use forks for pr's right?
    ✅ 1
  • j

    Joel Whalen

    10/13/2023, 3:29 PM
    Ok so I've opened a pull request but I'm not close to done yet, just want to track my work. I've got a basic graphql api working and now I just need to: 1. capture the requests with msw 2. write the unit test with this captured request 3. write the transformer to make it pass https://github.com/pactflow/pact-msw-adapter/pull/125/files
    👌 1
    y
    • 2
    • 2
  • j

    Joel Whalen

    10/13/2023, 7:13 PM
    I'm gonna put this on the shelf for the weekend, but could you take a look at this @Yousaf Nabi (pactflow.io)? Do
    yarn install
    and then `yarn test ./src/pactFromMswServerGql.msw.spec.ts`; notice how there aren't any requests being matched at all? Not even with
    { onUnhandledRequest: 'error' }
    set in the msw server? The closest issue I could find says the problem is in how the Apollo Client is setup, but you can see I'm passing in
    node-fetch
    to the client just fine in
    graphqlClient.ts
    . I'd like to write the logic for handling gql, but msw isn't seeing any requests, which means I cannot write any handlers for it yet. Thanks
    y
    • 2
    • 3
  • j

    Joel Whalen

    10/16/2023, 6:07 PM
    got MSW working with graphql in pact-msw-adapter wooo
    Copy code
    PASS  src/pactFromMswServerGql.msw.spec.ts
      API - With MSW mock generating a pact
        ✓ should get all books (34 ms)
    now to write and test the pactfile
    woo 1
    🎉 2
    hooray 1
    y
    • 2
    • 1
  • j

    Joel Whalen

    10/17/2023, 4:09 PM
    So I wrote the msw pact writefile test, and uh, it... passes? I was expecting it to fail. Does this pactfile look right? Again here is the PR for reference. You can run this test with
    Copy code
    yarn install
     yarn test ./src/pactFromMswServerGql.msw.spec.ts
    testConsumer-graphql.json
    y
    • 2
    • 11
  • j

    Joel Whalen

    10/23/2023, 6:21 PM
    Hey @Matt (pactflow.io / pact-js / pact-go) @Yousaf Nabi (pactflow.io) MSW just released a major upgrade that depends on the built in fetch in nodejs 18 https://mswjs.io/blog/introducing-msw-2.0/
    thankyou 1
    y
    • 2
    • 2
  • d

    Dale

    01/29/2024, 10:49 AM
    Hi there. Is it possible to change the path that’s reflected in the pact file? I’m using the bi-directional approach. With the consumer tests, using MSW I’m intercepting a URI that looks like this
    <https://base-url.com/service/v2/price/>
    . The tests run, and the pact file is generated. The path property for each endpoint defined as follows:
    "path": /service/v2/price/
    On the provider side, the path in the OAS doc is displayed simply as
    /price/
    (without the leading
    /service/v2/
    ). My problem: The
    can-i-deploy
    step fails due to the endpoint
    /service/v2/price/
    not existing in the provider spec. Strictly true, but I’d like to get rid of the leading
    /service/v2/
    . Can I do this programmatically?
    blobwave 1
    y
    • 2
    • 3
  • d

    Dale

    03/13/2024, 4:15 PM
    hi! Is there a way to suppress console outputs such as:
    [pact-msw-adapter] Adapter enabled
    when I run my tests?
    y
    • 2
    • 8