Skip to content

Mock external services in e2e tests - #1514

Merged
fennifith merged 1 commit into
add-video-embedfrom
enable-e2e-mocking
Jan 19, 2026
Merged

fennifith merged 1 commit into
add-video-embedfrom
enable-e2e-mocking

Conversation

@fennifith

Copy link
Copy Markdown
Member

Fixes #1511

Comment thread playwright.config.ts
/* CI=1 tells astro.config.ts to turn off the dev toolbar */
command: "CI=1 pnpm dev --port 8889",
/* USE_E2E_MOCKS=1 imports e2e/setup.ts, which mocks external services using MSW */
command: "CI=1 USE_E2E_MOCKS=1 pnpm dev --port 8889",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not setup a dependent project to setup mocks instead of an env variable?

I can see this as valuable if we need mocks in dev locally

https://playwright.dev/docs/test-global-setup-teardown

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSW needs to run in the same node process as the fetch() requests it needs to mock, so I'm not sure how that helps? ("setup" might be a misnomer here)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool makes sense!

@fennifith
fennifith merged commit 43dfac1 into add-video-embed Jan 19, 2026
@fennifith
fennifith deleted the enable-e2e-mocking branch January 19, 2026 03:31

This branch was previously deployed

1 inactive deployment
review — 85eb6eae Deployed Jan 19, 2026 by fennifith
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

Successfully merging this pull request may close these issues.

2 participants