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

Use extracted tests #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mrloop
Copy link

@mrloop mrloop commented Sep 23, 2022

Follow up to #1 & #2

Extract test to seperate package so interceptor packages can share a common test suite and import and run tests from extracted package mirage-interceptor-test. Goal would be to run mirage-msw against mirage-interceptor-test too, think will need to use headless browser though for msw to work, not sure as not used msw much or jest.

@cah-brian-gantzler
Copy link
Collaborator

This PR also contains the commits from the previous two PRs

@cah-brian-gantzler
Copy link
Collaborator

There is no actual file that details the contract that an interceptor MUST have with MirageJS. I think the contract should exist in MirageJS repo. Tests that validate that the contract is being honored should also reside in MirageJS, so I agree with you the tests should be extracted, but not to this repo but to MirageJS itself. That would be tests that test the contract.

Tests that test the interceptor itself should remain here as I know there are going to be differences in the interceptors. We are looking into the one for you about serializing array query params. There is a known difference otherwise though. Mirage documentation shows changing the mirage logging in the middle of a test, turning it on and off. Pretender supports this. However MSW does not support changing it after the initial start. This issue is kinda asking for a way to filter them. mswjs/msw#420 The point is there will be differences and we have to plan on them.

@cah-brian-gantzler
Copy link
Collaborator

I played around with extracting the tests a little. One thing is a problem is that pretender only runs in the browser (many tests are written than way), MSW runs in the browser and node. When running the tests but using MSW as the intercepter, it complains that the you are calling the browser version while running in node. I configured the MSW interceptor to take a param and started calling the other correct methods, but that means the tests NEED to know if they are using MSW or Pretender.

I also ran into another problem and just dropped it for the moment in order to concentrate on the actual problem.

Point is Im not sure if you can do one set of tests to rule them all. Have to figure out how to get tests to even run in jest (which seems to be node where QUnit seems to run in a headless browser)

@mrloop
Copy link
Author

mrloop commented Nov 18, 2022

tests should be extracted, but not to this repo but to MirageJS itself. That would be tests that test the contract.

That makes sense, then as part of the interceptor test run it'd import the mirage interceptor contract tests and run against them.

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