Fastcheck: Property based testing for JavaScript and TypeScript
dubzzz.github.io
dubzzz.github.io
And since clojurescript can be compiled and exported to JavaScript, this makes it available to JavaScript projects. A few years ago I packaged this up as https://github.com/glenjamin/checkers. I expect there are newer versions of the underlying library available now, but as I haven't been working in this ecosystem for a while, I haven't kept the package up to date.
Property based testing framework for JavaScript (like QuickCheck) written in TypeScript
- oneof can shrink
- map does not need unmap to be passed to be able to shrink
- can find bug (see bias in the doc) - in this example jsverify will not find any bugs: jsc.assert(jsc.forall(jsc.integer(),n => Math.abs(n) <= 50))*
- replay of previous runs based on seed + path
- race conditions detection
- model based testing
*The reason why it does not find the bug is that by default it will always generate small values. If you ask for jsc.integer(0, 1000000) then the test jsc.assert(jsc.forall(jsc.integer(0, 1000000),n => Math.abs(n) > 50)) will always be green too. Not with fast-check, it will find the issue for both cases.