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
While instance initializers are powerful and capable of doing what you describe using them for here, they are also (in my experience) pretty serious foot-guns and can make it very difficult for someone to find where something is actually configured—especially in a sufficiently large app.
An alternative recommendation and approach might be to set up the client explicitly during app boot (e.g. in the application controller or route), and to provide a test helper which does the same, so that for component tests where you care about it, you explicitly opt in:
This also makes it much clearer when reading the test that it does need this kind of thing, and isn’t just implicitly/magically working. We do this for a variety of kinds of test hooks on the app I work on and it's slightly more verbose, but way easier for people to understand.
The text was updated successfully, but these errors were encountered:
While instance initializers are powerful and capable of doing what you describe using them for here, they are also (in my experience) pretty serious foot-guns and can make it very difficult for someone to find where something is actually configured—especially in a sufficiently large app.
An alternative recommendation and approach might be to set up the client explicitly during app boot (e.g. in the application controller or route), and to provide a test helper which does the same, so that for component tests where you care about it, you explicitly opt in:
This also makes it much clearer when reading the test that it does need this kind of thing, and isn’t just implicitly/magically working. We do this for a variety of kinds of test hooks on the app I work on and it's slightly more verbose, but way easier for people to understand.
The text was updated successfully, but these errors were encountered: