Replies: 3 comments 17 replies
-
I've been using fast-check with vitest as much as possible! This could be great! |
Beta Was this translation helpful? Give feedback.
-
Following multiple requests to have a fuzzing approach natively in fast-check library, I started to dig a little bit more on the subject and thought back about this opened discussion. Actually, many people want fuzzing to be a thing in JavaScript and actually fast-check alone miss some parts of it, as vitest does. A good fuzzer (as the one of Go) requires a collaboration between the test runner and the fuzz system (fast-check is a fuzz system). My point is: we should probably call the function The normal test mode runs the test in a classical PBT manner. The fuzz mode could be inspired by what Go does with some kind of infinite runs or runs being capped by a time limit. Anyway, so far I implemented on a drafty version for the |
Beta Was this translation helpful? Give feedback.
-
Even though it's a somewhat different approach, in the project Jazzer.js we combined libFuzzer with Jest and thought about providing a similar integration with vitest. Perhaps we could collaborate on a vitest integrations to get the best of both approaches. Using |
Beta Was this translation helpful? Give feedback.
-
Hey 👋,
I'm Nicolas, core maintainer and main contributor to the project called fast-check. The project does property based testing and reaches 8 million (
650k when I opened the ticket) downloads a month at the moment.In a nutshell:
Property Based Tests is another way to test code. Instead of writing hard-coded tests (such as "startWith should return true for prefix='t' value='toto'"), we write tests following specs (such as "startWith should return true for any prefix and value=prefix+suffix").
I like to say that "it can detect the unexpected".
It can be pushed even further to detect race conditions, CVEs...
Why it matters?
Well, while classical tests are a must have for test frameworks, property based tests leverage them to next level by making tests able to find bugs earlier. Having such built-in in vitest would probably help the JavaScript community to embrace even more the technique (up to now all JavaScript property frameworks put together are gathering a bit less than 1M downloads per month with 650k for fast-check alone).
Some people asked such support on my side: dubzzz/fast-check#3054
Suggestions of integration
While the libraries can be used as standalone libraries next to any test framework, some binding making them better integrated with test runners can always help. For fast-check, I came up with an integration for Jest working as a standalone package providing an API rewiring Jest and fast-check for a better integration but as I'm starting one for Vitest I'm wondering if the best option would not be to just have it native.
My idea would be to come up with some kind of
it.prop
(see related topic for the binding between Jest and fast-check).Alternative way being: third-party package wiring vitest to fast-check such as
@fast-check/jest
but for vitest or users keep doing it on their side.👋 I opened the discussion mostly because I believe that providing such test technique directly within Vitest would help a lot the JavaScript community. If the idea of having such built-ins directly within Vitest is something that might be interested for Vitest, then I can probably give an hand and start an integration if I get some guidance and if an API is somehow accepted.
💡 Let me know if you need more context. I linked fast-check so that you can see more in depth what it's about.
Beta Was this translation helpful? Give feedback.
All reactions