docs icon indicating copy to clipboard operation
docs copied to clipboard

Migrate "Random testing in JS" snippet

Open hobovsky opened this issue 4 years ago • 5 comments

Breakdown of #5

Migrate the snippet Random testing in JavaScript from the old wiki.

hobovsky avatar Dec 30 '20 11:12 hobovsky

That page mentions QuickCheck. Note that https://github.com/dubzzz/fast-check is available now. The output is not great by default, but it can be customized if I remember correctly.

We can also consider packaging commonly used snippets too.

kazk avatar Dec 30 '20 21:12 kazk

testing fast-check: https://www.codewars.com/kumite/5fed081200e85f001da9bbe1?sel=5fed081200e85f001da9bbe1 Also there's a fork with a nasty workaround. Not sure how to customize that output.

Steffan153 avatar Dec 30 '20 23:12 Steffan153

I haven't tried, but from their docs: https://github.com/dubzzz/fast-check/blob/master/documentation/Tips.md#customize-the-reported-error

kazk avatar Dec 31 '20 00:12 kazk

Alright, cool: https://www.codewars.com/kumite/5fed4c3ea267f800094c3d68/?sel=5fed4c3ea267f800094c3d68

The problem now is, this Test Passed it puts because I didn't throw an error... Throwing an error would make ugly output again, so idk...

Also, the reporter would be something we'd want to include in a package somewhere, so you can do like const { reporter } = require('@codewars/utilities'); or whatever.

Steffan153 avatar Dec 31 '20 04:12 Steffan153

You can throw AssertionError and the reporter will know it was test failure and not some unexpected error. I forked your example.

kazk avatar Dec 31 '20 04:12 kazk