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
Copy file name to clipboardExpand all lines: docs/about/contributing/frontend.md
+10-20Lines changed: 10 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -259,18 +259,16 @@ We use [Formik](https://formik.org/docs) for forms along with
259
259
260
260
## Testing
261
261
262
-
We use three types of testing in our app: **End-to-end (E2E)**, **Integration**
262
+
We use three types of testing in our app: **End-to-end (E2E)**, **Integration/Unit**
263
263
and **Visual Testing**.
264
264
265
-
### End-to-End (E2E)
265
+
### End-to-End (E2E) – Playwright
266
266
267
267
These are useful for testing complete flows like "Create a user", "Import
268
-
template", etc. We use [Playwright](https://playwright.dev/). If you only need
269
-
to test if the page is being rendered correctly, you should consider using the
270
-
**Visual Testing** approach.
268
+
template", etc. We use [Playwright](https://playwright.dev/). These tests run against a full Coder instance, backed by a database, and allows you to make sure that features work properly all the way through the stack. "End to end", so to speak.
271
269
272
-
For scenarios where you need to be authenticated, you can use
If the test involves routing checks like redirects or maybe checking the info on
298
-
another page, you should probably consider using the **E2E** approach.
292
+
We use Jest mostly for testing code that does _not_ pertain to React. Functions and classes that contain notable app logic, and which are well abstracted from React should have accompanying tests. If the logic is tightly coupled to a React component, a Storybook test or an E2E test may be a better option depending on the scenario.
299
293
300
-
### Visual testing
294
+
### Visual Testing – Storybook
301
295
302
-
We use visual tests to test components without user interaction like testing if
303
-
a page/component is rendered correctly depending on some parameters, if a button
304
-
is showing a spinner, if `loading` props are passed correctly, etc. This should
305
-
always be your first option since it is way easier to maintain. For this, we use
306
-
[Storybook](https://storybook.js.org/) and
307
-
[Chromatic](https://www.chromatic.com/).
296
+
We use Storybook for testing all of our React code. For static components, you simply add a story that renders the components with the props that you would like to test, and Storybook will record snapshots of it to ensure that it isn't changed unintentionally. If you would like to test an interaction with the component, then you can add an interaction test by specifying a `play` function for the story. For stories with an interaction test, a snapshot will be recorded of the end state of the component. We use
297
+
[Chromatic](https://www.chromatic.com/) to manage and compare snapshots in CI.
308
298
309
299
To learn more about testing components that fetch API data, refer to the
310
300
[**Where to fetch data**](#where-to-fetch-data) section.
0 commit comments