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

replace continuables with async-await in tests #43

Merged
merged 8 commits into from
Jun 15, 2021
Merged

Conversation

staltz
Copy link
Member

@staltz staltz commented Jun 14, 2021

The new async-await control flow makes tests easier to read, since they are sequential (but still allow parallelism via Promise.all), a developer reading code doesn't have to jump their eyes up and down trying to follow the flow, and there's no callback pyramid.

In some cases I rewrote the tests, because they either didn't assert anything, or were using inconsistent patterns (it seems like some test files used one way of connecting, while other files used another method, seems to be that one method was an old style).

A big PR, but I feel confident about these tests are now readable and deterministic (don't rely on console.logs to do "human assertion").

@staltz staltz requested a review from arj03 June 14, 2021 15:13
@arj03
Copy link
Member

arj03 commented Jun 14, 2021

Wow, quite a PR. Overall from first look, this is a very nice cleanup.

test/index.js Outdated Show resolved Hide resolved
test/misc/util.js Outdated Show resolved Hide resolved
test/misc/util.js Outdated Show resolved Hide resolved
test/block.js Outdated Show resolved Hide resolved
test/block.js Outdated Show resolved Hide resolved
test/block.js Show resolved Hide resolved
test/index.js Outdated Show resolved Hide resolved
test/random.js Outdated Show resolved Hide resolved
test/random.js Outdated Show resolved Hide resolved
test/random.js Outdated Show resolved Hide resolved
@arj03
Copy link
Member

arj03 commented Jun 14, 2021

I ended up reading all the tests in the new version. They are actually quite readable now. Great job cleaning this up!

test/block.js Outdated Show resolved Hide resolved
@staltz
Copy link
Member Author

staltz commented Jun 15, 2021

@arj03 Check my latest commit, I think it should fully clarify test/block.js

@arj03
Copy link
Member

arj03 commented Jun 15, 2021

Yep. This is really great. I now want to start using ssb-ebt again in browser-core after reading these tests :)

@staltz
Copy link
Member Author

staltz commented Jun 15, 2021

Can I green?

@staltz staltz merged commit 6917ece into master Jun 15, 2021
@staltz staltz deleted the async-await-tests branch June 15, 2021 07:47
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