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

start using webfakes #4

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

start using webfakes #4

wants to merge 15 commits into from

Conversation

maelle
Copy link
Member

@maelle maelle commented Oct 16, 2020

Notes.

  • I created a JSON file by saving locally what I got in the browser. I could also have copy-pasted from the API docs. A developer would be expected to find their own workflows for creating fixtures, right?

  • With such a testing framework how do you check the API output didn't change? I can only think of scripting the fixture creation + looking at the git diff. And obviously, there's the indirect solution of running tests with real requests regularly.

@maelle maelle marked this pull request as ready for review October 20, 2020 11:39
DESCRIPTION Outdated Show resolved Hide resolved
app <- presser::new_app()
app$get("/", function(req, res) {
res$send_json(
list( components =
Copy link
Member Author

Choose a reason for hiding this comment

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

in this case I wrote the object to be returned by hand. This way my PR shows two methods (in one test the response is written in the test file, in the other case there's a JSON file that's loaded)

@maelle maelle mentioned this pull request Oct 21, 2020
@maelle
Copy link
Member Author

maelle commented Nov 6, 2020

👋 @gaborcsardi, any comment on the approach?

I might also add inst/real-tests and some Rbuildignore gymnastics in a scheduled workflow (to test real requests), as I did for httptest.

@gaborcsardi
Copy link

I'll just need a day or so to get back into thinking about presser setup.

@maelle
Copy link
Member Author

maelle commented Nov 6, 2020

no hurry, thanks

@gaborcsardi
Copy link

I think this is all good. One thing to consider is whether you want to create an app that is reused in multiple test files. Either in setup.R or the new helper.R way. I think it would be good to show that, because starting a new app in every test_that() is slow, so people get annoyed quickly as they add tests.

@maelle
Copy link
Member Author

maelle commented Nov 16, 2020

I make this point in the chapter actually, I hope it'd be enough?

What would be nice in the chapter actually is linking to a real-life PR, e.g. when/if you add presser tests to gh.

@maelle maelle changed the title start using presser start using webfakes Nov 26, 2020
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