Skip to content
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

Add a property based testing script #396

Closed
wants to merge 1 commit into from
Closed

Conversation

nono
Copy link
Contributor

@nono nono commented Nov 9, 2015

Hello,

I wanted to make some tests for awaitWriteFinish but it can take times to generate a lot of tests. I tried something called property based testing to generate these tests for me (with the jsverify lib). The tests are green on my machine (no bug found) but I wonder if it something you are interested in. Maybe we can add it to travis and appveyor to catch more bugs.

What do you think about this?

@es128
Copy link
Collaborator

es128 commented Nov 9, 2015

It's interesting, but I'm not yet persuaded it brings us much of an advantage. Seems like a powerful concept for "unit tests", but that isn't really what we're doing to test chokidar because of its unique circumstances compared with typical modules.

The tests actually act more as integration tests, involving the fairly flaky and unpredictable stack of low-level file system constructs under it. If we somehow mocked out the entire file system with predictable reactions, then we could perhaps have actual unit tests, but still that probably doesn't have much value here. The whole point of the library is to cover up the flakiness and inconsistencies, so you kind of want them present when testing.

Some ideas that I have become interested in regarding the tests are

  • to give each test a separate subdirectory sandbox instead of testing the exact same paths over and over - sometimes getting odd results out of all that churn (otoh sometimes catching edge cases because of it)
  • to explore separating file writing operations to be in a separate (child) process from the one doing the watching/detection
  • with the first item as a prerequisite, give AVA a try as a replacement for mocha, see if we can run all the tests much faster in parallel

Feel free to expand upon the advantages you perceive in what you've done in this PR to help me "see the light"

@es128 es128 mentioned this pull request Dec 7, 2015
@nono nono closed this Jan 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants