Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

Add an example file and test for using mock-inspect with nodejs #73

Closed
wants to merge 5 commits into from

Conversation

aychtang
Copy link

No description provided.

@aychtang aychtang requested review from rickschubert and a team as code owners June 18, 2021 16:18
@aychtang aychtang requested review from thomaschaplin and siva-natarajan and removed request for a team June 18, 2021 16:18
@aychtang
Copy link
Author

aychtang commented Jun 18, 2021

Hey guys, was looking at potentially adding some examples like I mentioned in #17.

There is an error with the example test I added:

 FAIL  examples/nodejs/nodeJsExample.spec.ts
  ● should send a request to https://example.com

    Unhandled error. (Error: [MSW] Error: captured a GET https://example.com/ request without a corresponding request handler.

      If you wish to intercept this request, consider creating a request handler for it:

      rest.get('https://example.com/', (req, res, ctx) => {
        return res(ctx.text('body'))
      })

      at onUnhandledRequest (node_modules/msw/node/index.js:2081:19)
      at Object.<anonymous> (node_modules/msw/node/index.js:2155:25)

but I'm not sure why this occurs. I don't really know about MSW but maybe I'm misusing mock-inspect in this case?

@aychtang
Copy link
Author

It doesn't seem to correctly mock the call in examples/nodejs/index.ts

@aychtang
Copy link
Author

aychtang commented Jun 18, 2021

Ok fixed it in d79931d, it's just that in the mocked request I was including www. in the requestPattern.

The github action is failing as the new test is not under rootDir which is currently /src, where do we want to put this stuff? I think it shouldn't be in /src as it's not source code for the app.

@aychtang aychtang mentioned this pull request Jun 18, 2021
@aychtang aychtang changed the title Howard/add nodejs example Add an example file and test for using mock-inspect with nodejs Jun 18, 2021
@thomaschaplin
Copy link
Member

@aychtang what's the status of this PR? Looks like the unit test pipeline is failing

@aychtang aychtang closed this Jun 28, 2021
@aychtang aychtang deleted the howard/add-nodejs-example branch June 28, 2021 13:53
@aychtang
Copy link
Author

I will add some kind of example as a separate repo which we can then link to from the README of the main project.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants