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: test/README.md
+16-4Lines changed: 16 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -46,11 +46,23 @@ In addition to an `index.js`, these configCases require a `webpack.config.js` is
46
46
#### statsCases (`StatsTestCases.test.js`)
47
47
Stats cases are similar to configCases except specifically focusing on the `expected` output of your stats. Instead of writing to the console, however the output of stats will be written to disk.
48
48
49
-
By default, the "expected" outcome is a pain to write by hand so instead when statsCases are run the following happens:
49
+
By default, the "expected" outcome is a pain to write by hand so instead when statsCases are run, runner is checking output using jest's awesome snapshot functionality.
50
50
51
-
* Checks for `expected.txt` file containing expected results.
52
-
* If the `expected.txt` doesn't match what is output, then an `actual.txt` stats output file will be created and the test will fail. (A typical workflow for stats cases is to fail the test and copy the results from `actual.txt` to `expected.txt`.)
53
-
* If the actual output matches `expected.txt`, the tests passes and you are free to submit that PR with pride!!!
51
+
Basically you don't need to write any expected behaviors your self. The assumption is that the stats output from your test code is what you expect.
52
+
53
+
Please follow the approach described bellow:
54
+
55
+
* write your test code in ```statsCases/``` folder by creating a separate folder for it, for example
56
+
```statsCases/some-file-import-stats/index.js```
57
+
```
58
+
import(./someModule);
59
+
```
60
+
** dont's forget the ```webpack.config.js```
61
+
* run the test
62
+
* jest will automatically add the output from your test code to ```StatsTestCases.test.js.snap``` and you can always check your results there
63
+
* Next time test will run -> runner will compare results against your output written to snapshot previously
64
+
65
+
You can read more about SnapShot testing [right here](https://facebook.github.io/jest/docs/en/snapshot-testing.html)
54
66
55
67
## Questions? Comments?
56
68
If you are still nervous or don't quite understand, please submit an issue and tag us in it, and provide a relevant PR while working on!
0 commit comments