question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Since v5.9.0 computed properties became not configurable. That’s probably why Sinon.js throws an error, while stubbing a getter: TypeError: Cannot redefine property.

Are there any ways to stub/spy a getter, best practices?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mweststratecommented, Feb 6, 2019

@mishk0

class X {

   @computed get nonStubable() {
     return this.stubablle()
   }

   /* private */ stubable() {
      // this one is stubable, but the indirection won't loose any of the semantic benefits of `nonStubable` 
   }
}
0reactions
lock[bot]commented, Jul 21, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Test React and MobX with Jest - Semaphore CI
Learn how to get started with unit testing for a React and MobX application using Enzyme and Jest, including continuous testing.
Read more >
React and Mobx Store Unit Testing and Mocking With Jest
React and Mobx Store Unit Testing and Mocking With Jest. ... Researching how to do unit tests of a Mobx store, I came...
Read more >
Unit testing with MobX - ITNEXT
Unit tests is every test that was built upon input or output declarations of a system(control data, usage procedures, and operating procedures).
Read more >
Testable state management using React Native with MobX
This article will go through how to manage the state of your React Native application and test it. We will be using the...
Read more >
Testing React MobX store? Cypress made it easy! - Medium
Snapshot testing has taken the JavaScript unit testing world by storm. Snapshot testing can be a very handy tool to test the MobX...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found