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

test: add isolated response test for iframes #2205

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

kettanaito
Copy link
Member

Adds an automated test for the isolated response scenario when using multiple iframes on the page.

How does this work?

Each iframe becomes the outgoing request's referrer. If the iframe provides a check in the request handlers to ignore a matching request if it has a referrer different from the current iframe's location.href, it will allow two iframes to receive different responses to the same request.

@kettanaito kettanaito changed the title test: add isolated response tests for iframes test: add isolated response test for iframes Jul 12, 2024
<script>
const { worker, http } = window.parent.msw

function isolatedResolver(resolver) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@yannbf, hi 👋 Let's try using this utility in the Storybook add-on and see if it provides us with the context isolation when rendering multiple stories on the same page (in iframes). I hope it does!

The important part here is so this utility runs in the iframe's context, not in the parent context.

@kettanaito kettanaito merged commit e52f10b into main Jul 18, 2024
12 checks passed
@kettanaito kettanaito deleted the test/iframe-isolated-response branch July 18, 2024 14:01
@kettanaito
Copy link
Member Author

Released: v2.3.2 🎉

This has been released in v2.3.2!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

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.

1 participant