-
Notifications
You must be signed in to change notification settings - Fork 339
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
Tests for Util Module #233
Conversation
This is awesome @reficul31! Thanks a lot for getting started on this. To reply to some of your points:
Feel free to upgrade test-related deps on this branch - shouldn't effect anything existing.
Seems fine! Reading through some of your tests, it's all very understandable. Will look over more thoroughly later
Same opinion as here, although tbh I'm not really fussed either way. What benefits would there be from having a separate dir tree for tests? Any personal recommendation?
I think positive cases are more important, but negative test cases would be very welcome in any module that expects some sort of user-defined input. Any suggestion? Some other things:
|
Thanks for replying quickly @poltak . To follow up some questions and answer some queries.
I would actually prefer the unit tests to be placed beside the modules and the integration tests placed in their own folders. This would allow us to run the testing suite simultaneously for the unit tests and the integration tests as integration tests would take more time.(We could also separate the snapshot tests of react. But that's a bridge we can cross once we get there.)
Oh. I thought the plugin was setup. I will set it up and maybe send it in another PR?
For sure, positive test cases are the most important and forms the basis of test based programming. I think we can add negative test cases in some modules to check and see what sort of behaviour is take up by it functions. Eg. Here are some examples of the negative test cases in a module.
Yeah I thought a lot about using mocha and its many many tools. But due to a variety of reasons I chose to go with jest.
Should I send the unit tests in batches and group them according to the modules or would it be much more easier to send individual files? I personally would prefer sending individual files so as to not clutter the discussion with too much code review. But I am open to suggestion. |
I think it's probably just a line in the conf or some dep - best to add in her,e as we don't really want to merge anything in that introduces lint issues (should be added as a failable CI stage when we get to that later). No issue with any of your points.
Does this mean grouping multiple module's unit tests in a single |
Sorry for the confusion. No, I just meant should I send the PRs containing tests for the whole modules like this one? Eg(Tests for util or tests for activity logger). Or should I separate the PRs by sending 1 PR for each file in a module? Eg(Tests for util/delay in one PR and similarly for other files) I would prefer having one PR for each file in the module. This way the code review won't get cluttered with all the inputs from all the files in the module. Also I feel it would be much more easier to review just one test at a time, as reviewing one full module of tests is a bit tedious. But I am open to suggestions. |
Short Update:
|
sure, send your PRs as you like :) The skipped tests - for |
Yes the test are skipped for the same reason as mentioned above. I would have disabled the warning but because it is short term, it is better to keep it. The new version of jest release will mostly take care of the problems in the tests. Actually, it came to my notice that the new version was made available 3 days ago. Just waiting for them to smooth out some of the bugs and then I will update. |
|
||
// We use a bogus await statement to let any resolved promises invoke their callbacks. | ||
// XXX Not sure if we can rely on this in every ES implementation. | ||
await null |
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.
How does await null
work? Wouldn't it just continue on immediately? Or is it similar to passing 0
to setTimeout
, putting the subsequent code at the end of the execution queue?
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.
Here is some context, I hope this provides some help regarding the clarification of the use of await null
. I am still searching for a better alternative. Hopefully the upgrade in jest might just resolve the issue.
@poltak Almost done? |
What's the status of this now? I'm happy to merge it in whenever you're finished making the changes you wanted to do
… On Jan 10, 2018, at 16:36, Shivang Bharadwaj ***@***.***> wrote:
@poltak Almost done?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I was thinking we could merge these for now and then I could send individual pull requests for the remaining files in the utils module so that it is easier to review and discuss? |
Great stuff @reficul31 . We should add our |
I am not completely sure about the pre commit hook for the test script. Since I was hoping to setup a CI as soon as the unit testing suite is up and running. Would running the tests twice in a pre commit hook as well as in a CI be counter intuitive? |
Yeah if you're gonna set up a CI server to handle all that, I think it should be fine to leave out of precommit. |
Refs
Some of the tests in this module are coded to be skipped due to some technical issues at the jest repository. Refer. Although it will be fixed once we upgrade to Jest22.
I would like to clear some doubts regarding the general construction of the testing suite.
Again, to rediscuss the issue of having tests in their own directory of
__tests__
in comparison to having them beside the module?In this PR I have written a combination of Positive and Negative tests. Would the devs like to follow the Positive style of testing or the Positive-Negative style of testing?
I have chosen to test the util module to be fully tested first as it is completely decoupled from the whole project. If we test the whole util module it would allow us to just pick up and use any function from this module without worrying too much about the implementation.