Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use @uppy/xhr with MSW mock server? #3717

Closed
wessankey opened this issue May 11, 2022 · 1 comment · Fixed by #3782
Closed

How to use @uppy/xhr with MSW mock server? #3717

wessankey opened this issue May 11, 2022 · 1 comment · Fixed by #3782
Labels

Comments

@wessankey
Copy link

wessankey commented May 11, 2022

I'm attempting to write unit tests for components that use Uppy to upload files, and am using MSW to mock a file server API. The XHRUpload plugin is being used for file uploads, but MSW isn't intercepting the upload requests.

Here is a code sandbox containing a demo app that demonstrates the issue I'm seeing. Note - the app will need to be cloned locally, as it requires Node to run. To reproduce what I'm seeing, run npm run test and notice that Uppy does successfully complete the upload, but the API response is not included in the result.

successful: [
        {
          source: 'file-input',
          id: 'uppy-file/jpg-1e-image/jpeg-1-1652304114460',
          name: 'file.jpg',
          extension: 'jpg',
          meta: [Object],
          type: 'image/jpeg',
          data: File {},
          progress: [Object],
          size: 1,
          isRemote: false,
          remote: '',
          preview: undefined
        }
]

Not sure if this is necessarily a feature request, as it seems like something that should be working. If there are examples of this working successfully with MSW (or any mocking library), I would definitely appreciate a link to an example.

@Murderlon
Copy link
Member

Hi, I'm not sure what is going on but I do know @uppy/xhr works as it should an implementing the receiving end is up to the implementer. I'm sorry I don't have examples.

Only thing I can quickly see it your test code uses api as the endpoint but that should probably be a full URL.

@Murderlon Murderlon changed the title MSW Integration How to use @uppy/xhr with MSW mock server? May 12, 2022
@Murderlon Murderlon linked a pull request May 25, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants