Skip to content

Replace invalid sinon.define with Object.defineProperty and cleanup#374

Merged
jankapunkt merged 3 commits into
release/2.4.1from
copilot/sub-pr-369
Jan 6, 2026
Merged

Replace invalid sinon.define with Object.defineProperty and cleanup#374
jankapunkt merged 3 commits into
release/2.4.1from
copilot/sub-pr-369

Conversation

Copilot AI commented Dec 17, 2025

Copy link
Copy Markdown

Addresses review feedback to fix test using non-existent sinon.define() API when globalThis.navigator is undefined.

Changes

  • Replaced sinon.define(globalThis, 'navigator', { language: 'de-DE' }) with Object.defineProperty()
  • Added try-finally block to delete the property after test execution
  • Set configurable: true and writable: true on the property descriptor

Implementation

let navigatorDefined = false
if (globalThis.navigator) {
  sinon.stub(globalThis.navigator, 'language').get(() => 'de-DE')
} else {
  Object.defineProperty(globalThis, 'navigator', {
    value: { language: 'de-DE' },
    configurable: true,
    writable: true
  })
  navigatorDefined = true
}

try {
  // test assertions
} finally {
  if (navigatorDefined) {
    delete globalThis.navigator
  }
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 17, 2025 08:46
…eanup

Co-authored-by: jankapunkt <1135285+jankapunkt@users.noreply.github.com>
Co-authored-by: jankapunkt <1135285+jankapunkt@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback on implementing Object.defineProperty Replace invalid sinon.define with Object.defineProperty and cleanup Dec 17, 2025
Copilot AI requested a review from jankapunkt December 17, 2025 08:54
@jankapunkt
jankapunkt marked this pull request as ready for review January 6, 2026 08:50
@jankapunkt
jankapunkt merged commit 4ba34ef into release/2.4.1 Jan 6, 2026
9 checks passed
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