diff --git a/test/README.md b/test/README.md index 97fb3320bff..f648f049744 100644 --- a/test/README.md +++ b/test/README.md @@ -46,11 +46,23 @@ In addition to an `index.js`, these configCases require a `webpack.config.js` is #### statsCases (`StatsTestCases.test.js`) 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. -By default, the "expected" outcome is a pain to write by hand so instead when statsCases are run the following happens: +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. -* Checks for `expected.txt` file containing expected results. -* 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`.) -* If the actual output matches `expected.txt`, the tests passes and you are free to submit that PR with pride!!! +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. + +Please follow the approach described bellow: + +* write your test code in ```statsCases/``` folder by creating a separate folder for it, for example +```statsCases/some-file-import-stats/index.js``` +``` + import(./someModule); +``` +** dont's forget the ```webpack.config.js``` +* run the test +* jest will automatically add the output from your test code to ```StatsTestCases.test.js.snap``` and you can always check your results there +* Next time test will run -> runner will compare results against your output written to snapshot previously + +You can read more about SnapShot testing [right here](https://facebook.github.io/jest/docs/en/snapshot-testing.html) ## Questions? Comments? 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! diff --git a/test/statsCases/accept-stats.js b/test/statsCases/accept-stats.js deleted file mode 100644 index 04ec7bab4d2..00000000000 --- a/test/statsCases/accept-stats.js +++ /dev/null @@ -1,15 +0,0 @@ -var fs = require("fs"); -var path = require("path"); -var dirs = fs.readdirSync(__dirname); -dirs.forEach(function(dir) { - var actual = path.join(__dirname, dir, "actual.txt"); - var expected = path.join(__dirname, dir, "expected.txt"); - try { - if(fs.existsSync(actual)) { - fs.unlinkSync(expected); - fs.renameSync(actual, expected); - } - } catch(e) { - console.log(e); - } -});