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 basic test for Fetch handler #8878

Merged
merged 4 commits into from
Sep 18, 2023
Merged

test: add basic test for Fetch handler #8878

merged 4 commits into from
Sep 18, 2023

Conversation

runspired
Copy link
Contributor

Adds @ember-data/mock-server, a private (for now) mock-server based on real HTTP requests.

The mock server can integrate with any app's test suite via an additional handler and a simple beforeEach/afterEach setup.

The mock server has the ability to both record and replay. Once a recording exists, replaying is extremely cheap due to http/2, careful mitigation of CORS pre-flighting, and all requests having been pre-compressed with brotli at 11.

Currently all mocking is done within the app and posted to the server.

@runspired runspired added 🎯 canary PR is targeting canary (default) 🏷️ test This PR primarily adds tests for a feature labels Sep 18, 2023
@@ -99,7 +99,7 @@ export function findRecord(

const url = buildBaseURL(urlOptions);
const headers = new Headers();
headers.append('Content-Type', 'application/json; charset=utf-8');
headers.append('Accept', 'application/json; charset=utf-8');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed Content-Type from the builders because we want the out-of-the-box CORS experience to be great, and CORS only allows Content-Type to be application/x-www-form-urlencoded multipart/form-data or text/plain before it will opt for a preflight request.

@runspired runspired merged commit 7ef07ee into main Sep 18, 2023
@delete-merged-branch delete-merged-branch bot deleted the mock-server branch September 18, 2023 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 canary PR is targeting canary (default) 🏷️ test This PR primarily adds tests for a feature
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant