diff --git a/src/__screenshots__/example.test.ts/calls-Amplify-downloadData-1.png b/src/__screenshots__/example.test.ts/calls-Amplify-downloadData-1.png deleted file mode 100644 index f88c55c..0000000 Binary files a/src/__screenshots__/example.test.ts/calls-Amplify-downloadData-1.png and /dev/null differ diff --git a/src/__screenshots__/example.test.ts/fetches-the-user-info-1.png b/src/__screenshots__/example.test.ts/fetches-the-user-info-1.png deleted file mode 100644 index f88c55c..0000000 Binary files a/src/__screenshots__/example.test.ts/fetches-the-user-info-1.png and /dev/null differ diff --git a/src/mocks/amplifyconfiguration_mock.json b/src/mocks/amplifyconfiguration_mock.json index 7e2709d..d0269b4 100644 --- a/src/mocks/amplifyconfiguration_mock.json +++ b/src/mocks/amplifyconfiguration_mock.json @@ -10,7 +10,7 @@ "aws_appsync_graphqlEndpoint": "https://mock.appsync-api.us-east-2.amazonaws.com/graphql", "aws_appsync_region": "us-east-2", "aws_appsync_authenticationType": "AWS_LAMBDA", - "aws_cognito_identity_pool_id": "us-east-2:mock", //This needs to be set to a real id, see README + "aws_cognito_identity_pool_id": "us-east-2:mock", "aws_cognito_region": "us-east-2", "aws_user_pools_id": "us-east-2_mock", "aws_user_pools_web_client_id": "mock", diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts index 3dc138b..0391452 100644 --- a/src/mocks/handlers.ts +++ b/src/mocks/handlers.ts @@ -1,4 +1,4 @@ -import { http, graphql, HttpResponse } from "msw"; +import { http, HttpResponse } from "msw"; export const handlers = [ http.post("https://cognito-identity.us-east-2.amazonaws.com/", () => { @@ -12,7 +12,28 @@ export const handlers = [ IdentityId: "us-east-2:mock", }); }), - + http.options( + `https://mock-staging.s3.us-east-2.amazonaws.com/path/to/file.json`, + () => { + return new Response(null, { + status: 200, + headers: { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "GET,HEAD,PUT,POST,DELETE", + "Access-Control-Allow-Headers": "*", + "Access-Control-Expose-Headers": + "x-amz-server-side-encryption, x-amz-request-id, x-amz-id-2, ETag", + "Access-Control-Max-Age": "3000", + "Content-Length": "0", + Date: "Fri, 03 Jan 2025 03:30:11 GMT", + Server: "AmazonS3", + Vary: "Origin, Access-Control-Request-Headers, Access-Control-Request-Method", + "x-amz-id-2": "mock", + "x-amz-request-id": "mock", + }, + }); + } + ), http.get( `https://mock-staging.s3.us-east-2.amazonaws.com/path/to/file.json`, () => { diff --git a/vitest.setup.ts b/vitest.setup.ts index c1ef549..f791113 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -1,9 +1,9 @@ import { Amplify } from "aws-amplify"; import { worker } from "./src/mocks/worker.js"; import amplifyconfig from "./src/mocks/amplifyconfiguration_mock.json"; -beforeAll(() => { +beforeAll(async () => { Amplify.configure(amplifyconfig); - worker.start(); + await worker.start(); }); afterEach(() => {