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 done w/ async in tests part 1 #3413

Merged
merged 3 commits into from
Mar 22, 2021

Conversation

mdrichardson
Copy link
Contributor

@mdrichardson mdrichardson commented Mar 18, 2021

Partial fix for #3226. This will be done in multiple PRs.

Covers

(Alphabetically such that botbuilder comes before botbuilder-)

  • adaptive-expressions-ie11 through botbuilder, inclusive

Excludes

Description

Replaces the use of done() in tests with proper async/await.

Specific Changes

  • done => async/await
  • Remove done completely when used in synchronous tests. For example, it was in some beforeEach() hooks, but it's not needed; nock doesn't even use it there
  • Remove some of the try/catches that are no longer needed since we don't need done(err)
  • Avoid arrow function in mocha tests
  • A lot of no-op stuff auto-fixes with our prettier/eslint settings

Notes (mostly for me)

  • Regex for finding done usage: (done =>)|\(done\)
  • Search in: ./libraries/**/**/tests/**/*.js
  • For adding await to adapter.send() calls: (?<!(await)|(const))\sadapter

@coveralls
Copy link

coveralls commented Mar 18, 2021

Pull Request Test Coverage Report for Build 676755689

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 85.084%

Totals Coverage Status
Change from base Build 665654550: 0.04%
Covered Lines: 18786
Relevant Lines: 21032

💛 - Coveralls

@mdrichardson
Copy link
Contributor Author

mdrichardson commented Mar 19, 2021

@joshgummersall @stevengum I opted not to make changes to channelServiceRoutes.test.js because the conversion isn't as straight-forward. I could leave it as-is, or implement something like this. Preference?

Edit: Josh and I discussed offline and decided it's best to leave as-is.

@mdrichardson mdrichardson changed the title Replace done w/ async in tests Replace done w/ async in tests part 1 Mar 19, 2021
Copy link
Contributor

@joshgummersall joshgummersall left a comment

Choose a reason for hiding this comment

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

@mdrichardson, one thing that might be helpful is to add https://www.npmjs.com/package/eslint-plugin-mocha for our test files. One reason is that it enforces using function () {} instead of () => {}. We have a section in the root eslint configuration that does some test-specific overrides (see here). Hopefully, we can add the mocha plugin to this configuration. Can you give that a shot?

libraries/botbuilder/tests/inspectionMiddleware.test.js Outdated Show resolved Hide resolved
@mdrichardson mdrichardson marked this pull request as ready for review March 22, 2021 16:38
@mdrichardson mdrichardson requested a review from a team as a code owner March 22, 2021 16:38
@joshgummersall joshgummersall merged commit d28a2ea into microsoft:main Mar 22, 2021
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.

3 participants