You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternative is getting the instance in the test scope but restoring everything at the teardown, I guess. But it feels weird to copy paste drive mocking setup in each test.
test.group("foo endpoint",(group)=>{group.each.teardown(async(test)=>{Drive.restoreAll();});test("mocked disk test",async({test: { context }})=>{constdrive=Drive.fake("gcs");// send request here// assertionsassert.equal(awaitdrive.get('package.json'),JSON.stringify({}))// let the teardown hook do the cleanup});});
Package version
v2.0.7
The text was updated successfully, but these errors were encountered:
brkn
changed the title
Should setup inject stuff into test context
Should setup group-hook inject stuff into test context
May 14, 2022
Since the APIs allows you to inject custom properties in the context, you can do that. Yes, it is not documented, because not everything can be captured in documentation and a lot of stuff is about experimenting and building custom flows around the public APIs.
I guess. But it feels weird to copy paste drive mocking setup in each test.
It depends on how you like to code. I am personally okay with copy/pasting code within multiple tests and do not try to remove every duplicate line of code. Dan Abramov (maintainer of React) wrote a great article on the same https://overreacted.io/the-wet-codebase/.
I will close the issue as there is nothing actionable here 👍
Description
I've tried injecting stuff into the test context and it worked. But this is not documented, is this a bad pattern?
Alternative is getting the instance in the test scope but restoring everything at the teardown, I guess. But it feels weird to copy paste drive mocking setup in each test.
Package version
v2.0.7
The text was updated successfully, but these errors were encountered: