MSW with Playwright, GraphQL and Remix SSR #2402
Unanswered
pedro-novo-fanduel
asked this question in
Q&A
Replies: 1 comment
-
Very interesting. Also curious for a solution here. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm currently facing a problem with integration testing that I need some help with.
My goal is to mock SSR requests on a per-test suite basis while still allowing the tests to run in parallel. I came across an approach that aligns with this discussion, but I've run into some challenges that I haven't been able to overcome yet.
So I basically have an
api.mock.ts
middleware that allows me to access the server instance in order to mock the requests on the demand.And the way I interact with goes as follows (ignore the data structure, I'm just trying things out):
In a test setup, it would be something like:
The problem I'm having is that the 1st and 2nd nested test suite - test.describe - are mocking the same query
queryName: 'GameRules'
but with different responses, and since tests are running in parallel, I get the same response for both tests.This, I believe, must be related to the fact that both handlers are being registered with the same name, but MSW is not able to know which one to serve, since there's no specificity besides the name, so it serves the last one registered (I might be wrong here).
Running tests sequentially could solve this, but it would significantly slow down our pipeline, so it's not really an option we're considering.
Beta Was this translation helpful? Give feedback.
All reactions