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

Snapshot and Fake Tests Later #128

Merged
merged 19 commits into from
Apr 30, 2023
Merged

Conversation

johguentner
Copy link
Member

@johguentner johguentner commented Mar 5, 2023

With the help of the PestHttpRecorder::class and HttpRecorder::class, all external requests (done with the Http Facade) during testing, will be intercepted, saved as snapshot and faked for the same requests for future tests.

This is increases the validity of all snapshots, which fake requests during testing (important for fast tests and testing within CI).

If new tests are written, the snapshots will we generated locally automatically. After breaking changes of the Notion API, the generation of the snapshots can be forced, to keep validity of tests at a high level.

johguentner and others added 9 commits February 18, 2023 21:32
- load `NOTION_API_TOKEN`
- important for later tests
- allows to register the `Http` macro `recordAndFakeLater`
- this allows to create records for http requests, which will be stored and faked later to avoid calling API endpoints
- if the service is running in the console
- which has similar functionality as previous, however tests with the new `Http::recordAndFakeLater` macro
- for comments endpoint
@what-the-diff
Copy link

what-the-diff bot commented Mar 5, 2023

  • Added .env* to gitignore
  • Created a new file PestPluginHttpRecorder which registers the Http::recordAndFakeLater macro for use in tests
  • Updated LaravelNotionApiServiceProvider to register this plugin when running in console mode (i.e., during testing)

@johguentner johguentner added this to the 🍵 v1.1.0 milestone Apr 10, 2023
johguentner and others added 5 commits April 30, 2023 10:45
- change `plugin` to `macro`, because it is a more accurate definition
- .env.testing is only required during local tests, especially for creating new snapshots, on ci it is not required
@johguentner johguentner marked this pull request as ready for review April 30, 2023 02:14
@johguentner johguentner changed the title Refactor/record and fake tests Snapshot and Fake Tests Later Apr 30, 2023
@johguentner johguentner requested a review from mechelon April 30, 2023 06:53
@johguentner johguentner merged commit 6d990af into dev Apr 30, 2023
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