codewars / docs

The Codewars Docs :construction: WIP
https://docs.codewars.com
MIT License
56 stars 201 forks source link

Migrate "Random testing in JS" snippet #206

Open hobovsky opened 3 years ago

hobovsky commented 3 years ago

Breakdown of #5

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

kazk commented 3 years ago

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.

Steffan153 commented 3 years ago

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.

kazk commented 3 years ago

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

Steffan153 commented 3 years ago

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.

kazk commented 3 years ago

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