-
-
Notifications
You must be signed in to change notification settings - Fork 178
test: add property based tests via fast-check #791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add property based tests via fast-check #791
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
test/unit/shared/utils/async.spec.ts
Outdated
| it('not run more than concurrency tasks in parallel', async () => { | ||
| await fc.assert( | ||
| fc.asyncProperty( | ||
| fc.array(fc.anything()), // TODO, support failing tasks too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not implemented the failing task part yet, but if the idea of adding property based testing to this repository feels sane I can work on adding this failure case (probably into a distinct test case mixing successes and failures but having a different expectation - highly depends on the behavior expected in case of failure)
|
@43081j @danielroe Given we discussed of the idea together on Bluesky and Discord |
|
I think this is correct:
this is how vue-router renders links with |
|
@danielroe Indeed you're right it's correct, I did the test on my browser and |
|
Tests adapted, sorry for the false warning |
|
Thanks ! I'm gonna propose other tests in the coming days. |
This PR proposes to add some tests using property based testing to the project.
Why?
The idea behind property based testing is that uncovering all bugs and edge-cases is often impossible as one cannot think of all of them. With this technique in place, developers can rely on the framework to find the issue without to think about all possible dangerous combinations that could exist.
Contrary to using random values in tests, property based tests are deterministic and reproducible as everything relies on a seed.
It may have found a bug...
The tests on parseJsDocLinks that I added are failing. Before trying to fix anything (the code or the test) I wanted to get a few insights from people knowing this piece of code.
Current failure is for a text being:
{@link http://a.aa/&}.More
Last point, adding a native support to Vitest is (by far) the most upvoted idea at the moment: vitest-dev/vitest#2212. While waiting for that to be true, we can use
@fast-check/vitest.