Skip to content

Refactor watch tests to avoid using test.cb - #533

Merged
RyanZim merged 2 commits into
masterfrom
ryan/refactor-watch-tests
Aug 27, 2026
Merged

Refactor watch tests to avoid using test.cb#533
RyanZim merged 2 commits into
masterfrom
ryan/refactor-watch-tests

Conversation

@RyanZim

@RyanZim RyanZim commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors watch tests from AVA callback APIs to async promises, supporting newer AVA versions.

Changes:

  • Replaces test.cb and t.end.
  • Adds promise-based process cleanup and assertions.
  • Clarifies a dependency test name.
Suppressed comments (4)

test/watch.js:415

  • Ignoring the promise returned by finally() creates an unhandled rejected promise whenever this test's deferred promise rejects. Run the cleanup through handlers for both fulfillment and rejection so the derived promise is handled.
    promise.finally(() => {
      try {
        if (processRunning) cp.kill()
      } catch {}
    })

test/watch.js:528

  • Ignoring the promise returned by finally() creates an unhandled rejected promise whenever this test's deferred promise rejects. Run the cleanup through handlers for both fulfillment and rejection so the derived promise is handled.
      promise.finally(() => {
        try {
          if (processRunning) cp.kill()
        } catch {}
      })

test/watch.js:319

  • Ignoring the promise returned by finally() creates an unhandled rejected promise whenever this test's deferred promise rejects. Run the cleanup through handlers for both fulfillment and rejection so the derived promise is handled.
    promise.finally(() => {
      try {
        if (processRunning) cp.kill()
      } catch {}
    })

test/watch.js:143

  • finally() returns a new promise that preserves the original rejection. Since that returned promise is ignored, a failure also creates an unhandled rejection rather than only rejecting the promise awaited by AVA. Handle both outcomes explicitly when running the cleanup.
    promise.finally(() => {
      try {
        if (processRunning) cp.kill()
      } catch {}
    })

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/watch.js Outdated
Comment thread test/watch.js

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread test/watch.js
@RyanZim
RyanZim merged commit b92aa6f into master Aug 27, 2026
7 checks passed
@RyanZim
RyanZim deleted the ryan/refactor-watch-tests branch August 27, 2026 20:00
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