Skip to content

fix(test): make tests pass with latest Deno and sinon 22 - #470

Merged
Shougo merged 2 commits into
vim-denops:mainfrom
haruyama:fix/worker-test-sinon22
Oct 12, 2026
Merged

Shougo merged 2 commits into
vim-denops:mainfrom
haruyama:fix/worker-test-sinon22

Conversation

@haruyama

@haruyama haruyama commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes two test failures that block #469 (and the 2.x jobs on main).

1. worker_test.ts fails with sinon 22

#469 bumps sinon from ^21.0.0 to ^22.1.0, and Test fails on all platforms:

error: TypeError: Cannot read properties of undefined (reading 'get')
    at getAccessor (.../sinon/22.1.0/pkg/sinon-esm.js:10017:23)
    at Function.restore (...)
    at Sandbox.restore (...)
    at Object.[Symbol.dispose] (denops/@denops-private/worker_test.ts:66:15)

error: TypeError: Cannot define the already existing property onmessage. Perhaps you meant sandbox.replace()?
    at Sandbox.define2 [as define] (...)
    at stubMessage (denops/@denops-private/worker_test.ts:55:11)

stubMessage() added postMessage / onmessage with sandbox.define() and then stubbed them with sandbox.stub() in the same sandbox. sinon 22 restores sandbox fakes in a different order, so the defined properties were removed before the stubs on them were restored. The first restore() throws, the properties are left behind, and every following step fails on define().

→ Use a separate sandbox for define() and restore it after the stub sandbox.

2. shared_server_test.ts fails with the latest Deno 2.x

AssertionError: Expected error message to include "Signal timed out",
  but got "The operation was aborted due to timeout".

The message of the AbortSignal.timeout() error changed in recent Deno. #469 replaces the expected string with the new one, but that would break the 2.3.0 job instead.

→ Check that a DOMException named TimeoutError is thrown, which is defined by the web standard and does not depend on the Deno version.

Test plan

  • worker_test.ts with sinon@^21.0.0 (current): ok | 4 passed (184 steps)
  • worker_test.ts with sinon@^22.1.0 (as in Update deps #469): ok | 4 passed (184 steps)
  • shared_server_test.ts with Deno 2.9.7: passed
  • deno fmt --check / deno lint / deno check
  • CI (including the 2.3.0 job)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved test isolation by ensuring temporary worker-message mocks are fully restored after each test.
    • Updated startup-timeout checks to recognize the standard timeout error across Deno versions, avoiding reliance on version-specific error messages.
    • These changes affect test reliability and compatibility; no user-facing behavior changes are included.

sinon 22 restores sandbox fakes in a different order, so the properties
added by `sandbox.define()` were removed before the stubs on them were
restored, breaking `stubMessage()` and cascading failures in subsequent
steps. Use a separate sandbox for `define()` and restore it last.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 34cb173b-ea90-476e-a5e4-2d90994d83a6


📥 Commits

Reviewing files that changed from the base of the PR and between 51fefba and ea1c4cf.



📒 Files selected for processing (1)
  • tests/denops/testutil/shared_server_test.ts


Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The worker message test helper separates property definitions from stubs and restores both sandboxes. The startup-timeout test checks the rejection type and name instead of requiring an exact message.

Changes

Worker test helper

Layer / File(s) Summary
Separate sandbox lifecycle
denops/@denops-private/worker_test.ts
stubMessage defines worker-global properties in a separate sandbox from its stubs. The disposer restores the stub sandbox before the property-definition sandbox.

Startup timeout test

Layer / File(s) Summary
Timeout error assertion
tests/denops/testutil/shared_server_test.ts
The startup-timeout test checks that the rejection is a DOMException named TimeoutError. A comment notes that timeout messages vary between Deno versions.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix



Merge Risk: ⚪ Minimal · up to ea1c4

The timeout assertion accommodates differences in error messages across supported Deno versions. No merge-blocking issue is identified.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately summarizes the main changes: updating tests for compatibility with newer Deno behavior and Sinon 22 restoration behavior.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.19%. Comparing base (1df7a02) to head (ea1c4cf).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #470      +/-   ##
==========================================
+ Coverage   96.05%   96.19%   +0.14%     
==========================================
  Files          29       29              
  Lines        1421     1421              
  Branches      191      190       -1     
==========================================
+ Hits         1365     1367       +2     
+ Misses         43       41       -2     
  Partials       13       13              

☔ View full report in Codecov by Harness.
📢 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.

…er_test

The message of the `AbortSignal.timeout()` error changed in recent Deno
("Signal timed out" -> "The operation was aborted due to timeout").
Check that a `DOMException` named `TimeoutError` is thrown instead, so
the test passes regardless of the Deno version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@haruyama haruyama changed the title fix(test): restore stubs before defined properties in worker_test fix(test): make tests pass with latest Deno and sinon 22 Oct 12, 2026
@haruyama

Copy link
Copy Markdown
Contributor Author

The only remaining failure, test (windows-latest, 2.x, v9.1.1646, v0.11.3), looks flaky and unrelated to this PR.

All tests passed in the Test step (ok | 57 passed (1690 steps) | 0 failed). The job failed in the subsequent deno task coverage --lcov step because one of the coverage files was empty:

error: Failed reading 'D:\a\denops.vim\denops.vim\.coverage\cec1ae23-76fc-40ba-ac2b-284bde453f92.json'

Caused by:
    EOF while parsing a value at line 1 column 0

All other jobs passed. Could someone with write access re-run the failed job? Thanks!

@Shougo

Shougo commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Thank you. I will test it on the local.

@Shougo Shougo 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.

I have tested on the local.

LGTM.

@Shougo
Shougo merged commit bb4563c into vim-denops:main Oct 12, 2026
8 of 10 checks passed
@Shougo

Shougo commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Merged. Thank you!

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