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

vitest browser mode issues #130

Open
charlieforward9 opened this issue Dec 20, 2024 · 1 comment
Open

vitest browser mode issues #130

charlieforward9 opened this issue Dec 20, 2024 · 1 comment

Comments

@charlieforward9
Copy link

I am having a lot of trouble with vitest browser mode and this mocking. I am trying to create a reproduction in one of the StackBlitzs' but not having much success.

With msw browser and vitest browser configured, I am unable to run this snippet.

import { describe, expect, it } from "vitest";
import { downloadData } from "aws-amplify/storage";

it("should download data", async () => {
  const data = downloadData({ path: "mock.json" }); //[ERROR] 01:19.801 xhr-http-handler - Network Error
  const result = await data.result;
  expect(result).toBeDefined();
});

It works in-app, and with setupServer mocking, but when I switch over to browser mode, it fails.

[ERROR] 01:19.801 xhr-http-handler - Network Error

Amplify requires an auth request prior to calling any of its APIs, and these mocked requests are fulfilled with my mocked auth responses located right next to the mocked S3 mocks.

I have to move to Browser mode to test my Leaflet map interactions, this is a severe blocker for my progress.

@charlieforward9
Copy link
Author

charlieforward9 commented Dec 20, 2024

The sample of the issue and a good future example of running in browser mode is here https://github.com/Agriculture-Intelligence/msw-vitest-browser-issue

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

No branches or pull requests

1 participant