Skip to content

chore: removes done callbacks in tests [CHORE-1870] #1875

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

Merged
merged 13 commits into from
May 8, 2025

Conversation

yowainwright
Copy link
Member

@yowainwright yowainwright commented Apr 27, 2025

Checklist

Chore: removes done callback; prefer async

  • I have ensured my pull request is not behind the main or master branch of the original repository.
  • I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
  • I have written a commit message that passes commitlint linting.
  • I have ensured that my code changes pass linting tests.
  • I have ensured that my code changes pass unit tests.
  • I have described my pull request and the reasons for code changes along with context if necessary.

@yowainwright yowainwright force-pushed the CHORE-1870-prefer-async-tests branch from efa8258 to cf39839 Compare April 27, 2025 21:11
Copy link

codecov bot commented Apr 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.90%. Comparing base (61bf494) to head (ee138b3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1875   +/-   ##
=======================================
  Coverage   99.90%   99.90%           
=======================================
  Files           9        9           
  Lines        2049     2049           
=======================================
  Hits         2047     2047           
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yowainwright yowainwright force-pushed the CHORE-1870-prefer-async-tests branch from cf39839 to 09614e8 Compare April 27, 2025 21:20
@yowainwright yowainwright marked this pull request as ready for review April 27, 2025 21:21
@yowainwright yowainwright marked this pull request as draft April 27, 2025 21:21
@jonathanong jonathanong requested a review from Copilot April 27, 2025 21:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR cleans up the test suite by refactoring tests to use async/await instead of callback-based done functions. Key changes include refactoring the test cases in multiple test files to an async style, removing outdated done callback usages, and updating event handling accordingly.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/response/writable.test.js Converted tests to async/await and removed done callbacks.
tests/response/redirect.test.js Updated redirect test from callback to async/await style.
tests/response/flushHeaders.test.js Refactored tests to async with updated error handling.
tests/request/href.test.js Changed test callback style to async/await.
tests/context/onerror.test.js Converted error-handling tests to async/await style.
tests/application/respond.test.js Switched from callback to async/await in error emission tests.
tests/application/index.test.js Updated socket error tests to async style for consistency.

@yowainwright yowainwright force-pushed the CHORE-1870-prefer-async-tests branch 3 times, most recently from 6ff69b2 to 609aa63 Compare April 27, 2025 21:46
@yowainwright yowainwright force-pushed the CHORE-1870-prefer-async-tests branch from 609aa63 to 83e2601 Compare April 27, 2025 21:52
@yowainwright yowainwright requested a review from Copilot April 27, 2025 21:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors test files to remove done callbacks in favor of async/await. The changes streamline asynchronous operations and simplify error handling across various test suites.

  • Converted tests from callback-based patterns to async/await.
  • Replaced custom request functions with supertest’s promise-based API.
  • Reorganized error handling for improved consistency.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/response/writable.test.js Refactored continuous requests test to use async/await and once events.
tests/response/redirect.test.js Converted redirect tests to async/await and removed done callbacks.
tests/response/flushHeaders.test.js Updated tests for flushHeaders with async/await and improved error triggering.
tests/request/href.test.js Modernized GET request test by replacing HTTP module code with supertest.
tests/context/onerror.test.js Refactored error handling tests to use async/await in onerror scenarios.
tests/application/respond.test.js Updated error emission tests to employ async/await.
tests/application/index.test.js Replaced callback style with async/await for socket error handling.
tests/application/flushHeaders.test.js Added a new async/await test file for flushHeaders functionality.

@yowainwright yowainwright marked this pull request as ready for review April 27, 2025 21:56
port
})
.on('response', res => {
const onData = () => done(new Error('boom'))
Copy link
Member

Choose a reason for hiding this comment

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

hmmm I'm not sure what this test is doing, I need to look deeper

const onData = () => done(new Error('boom'))
res.on('data', onData)

// shouldn't receive any data for a while
Copy link
Member

Choose a reason for hiding this comment

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

this test is not valid since the listener is added and removed and the test is complete on the same tick - the logic only happens on next tick. we can keep it for now but it's a bad test

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 updated this test! 👀

@yowainwright yowainwright merged commit 9057541 into master May 8, 2025
6 checks passed
@yowainwright yowainwright deleted the CHORE-1870-prefer-async-tests branch May 8, 2025 07:06
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.

2 participants