Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Remove chai-as-promised and convert tests to async/await #690

Merged
merged 14 commits into from
Feb 27, 2020

Conversation

dstaley
Copy link
Member

@dstaley dstaley commented Feb 26, 2020

In preparation for running tests in an actual browser environment, I've refactored all the tests that relied on chai-as-promised to async/await. In the process I discovered several tests that weren't waiting on promises correctly, and were throwing unhandled rejections.

Removing chai-as-promised was necessary to get the tests passing in Intern. I'll send a future PR actually adding Intern, but I figured this would be a good PR to merge even without Intern.

@dstaley
Copy link
Member Author

dstaley commented Feb 26, 2020

@leplatrem would love a quick spot check on this! For the most part it's exactly the same, so just skimming the changes and checking a few spots would be really appreciated!

Copy link
Contributor

@leplatrem leplatrem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

return getBlogBucket()
.getData()
.should.become({ foo: "bar" });
((await getBlogBucket().getData()) as { foo: string }).should.deep.equal({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in this case, an intermediary variable would make sense

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the tests to use an intermediary variable whenever we were casting an awaited value. However, we still have tests that look like this:

(await api.fetchServerInfo()).should.deep.equal(fakeServerInfo);

Is this clear enough, or should we lift all awaited calls into variables?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was like one of the few complex ones. Thanks for the changes!

test/integration_test.ts Outdated Show resolved Hide resolved
@leplatrem leplatrem merged commit dc130c1 into master Feb 27, 2020
@leplatrem leplatrem deleted the ds/promises-to-async branch February 27, 2020 23:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants