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
{{ message }}
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: .github/add-a-feature.md
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@
14
14
-[Using prop interfaces and propTypes](#using-prop-interfaces-and-proptypes)
15
15
-[State](#state)
16
16
-[Conformance Test](#conformance-test)
17
+
-[Performance Test](#performance-test)
17
18
-[Add doc site example](#add-doc-site-example)
18
19
-[Commit Messages](#commit-messages)
19
20
-[Open PR](#open-pr)
@@ -163,6 +164,10 @@ class MyComponent extends AutoControlledComponent<MyComponentProps> {
163
164
164
165
Review [common tests](test-a-feature.md#common-tests) below. You should now add the [`isConformant()`](test-a-feature.md#isconformant-required) common test and get it to pass. This will validate the `displayName` and `className` and multiple other aspects to help you get your component off the ground.
165
166
167
+
### Performance Test
168
+
169
+
Add a [performance test](test-a-feature.md#performance-tests) to set a baseline performance measurement for your component and guard against future regressions.
170
+
166
171
### Add doc site example
167
172
168
173
Create a new documentation example that demonstrates usage of the new feature.
Copy file name to clipboardExpand all lines: .github/test-a-feature.md
+44-2Lines changed: 44 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -17,14 +17,17 @@ Test a feature
17
17
-[Important mentions:](#important-mentions)
18
18
-[Run Screener tests](#run-screener-tests)
19
19
-[Local run command](#local-run-command)
20
-
-[Behavior tets](#behavior-tets)
20
+
-[Behavior Tests](#behavior-tests)
21
21
-[Adding test(s)](#adding-tests)
22
22
-[Running test(s)](#running-tests)
23
23
-[Troubleshooting](#troubleshooting)
24
24
-[I am not sure if my line under `@specification` was process correctly](#i-am-not-sure-if-my-line-under-specification-was-process-correctly)
25
25
-[I am not sure if my line was executed](#i-am-not-sure-if-my-line-was-executed)
26
26
-[I want to add any description which should not be consider as unit test](#i-want-to-add-any-description-which-should-not-be-consider-as-unit-test)
27
27
-[I want to create unit tests in separate file not through the regex](#i-want-to-create-unit-tests-in-separate-file-not-through-the-regex)
28
+
-[Performance Tests](#performance-tests)
29
+
-[Adding a Perf Test](#adding-a-perf-test)
30
+
-[Running Perf Tests](#running-perf-tests)
28
31
29
32
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
30
33
@@ -172,7 +175,7 @@ When ran locally, not all the tests may be needed to run, only the ones added/ed
172
175
yarn test:visual
173
176
```
174
177
175
-
## Behavior tets
178
+
## Behavior Tests
176
179
177
180
Behavior unit tests are generated from the specification written in each behavior file.
178
181
Each line under the `@specification` tag is taken and matched against the regex expression written in `testDefinitions.ts` file.
@@ -236,3 +239,42 @@ Add description under the `@description` tag. Like:
236
239
237
240
#### I want to create unit tests in separate file not through the regex
238
241
Add your spec file into the array of files `skipSpecChecksForFiles` in `testHelper.tsx`. And put description in behavior file under `@description` tag.
242
+
243
+
## Performance Tests
244
+
245
+
Performance tests will measure performance, set a baseline for performance and help guard against regressions.
246
+
247
+
### Adding a Perf Test
248
+
249
+
- To add a perf test, simply add a file with `.perf.` in its naming. (As of writing, `.perf.` files in `docs/src` and `packages/perf-test` are automatically consumed.)
250
+
- Formatting follows [Storybook CSF convention](https://storybook.js.org/docs/formats/component-story-format/) with special support for `iterations` metadata which tells the performance testing package how many iterations of your component to render:
251
+
252
+
```tsx
253
+
// If this file is named ButtonBasic.perf.tsx, it will be picked up as kind of 'ButtonBasic' with story names of 'Blank' and 'WithText'.
Finding the right number of `iterations` is a balancing act between having a fast test and getting enough information from the results. For more complex scenarios and components 1 iteration may be enough, while simple components with simple stories may need as many as 5,000.
263
+
264
+
### Running Perf Tests
265
+
266
+
Run test and watch:
267
+
```
268
+
cd packages/perf-test
269
+
yarn just perf-test
270
+
```
271
+
272
+
After running `perf-test`, results can be viewed in the `packages/perf-test/dist` folder with the main entry file being `packages/perf-test/dist/perfCounts.html`.
273
+
274
+
There are more detailed commands as well (these must be run from `packages/perf-test` directory):
275
+
276
+
| Command | Description |
277
+
|---------|-------------|
278
+
|`yarn just perf-test:bundle`| Recreates story bundle. Required if perf stories are added or modified. |
279
+
|`yarn just perf-test:run`| Runs flamegrill against story bundle and generates results. |
280
+
|`yarn just perf-test`| Executes both `:bundle` and `:run`. |
0 commit comments