Unit tests with Decorators
See original GitHub issueHello,
I’m using sesssionStorage decorator inside a service which I want to test.
Because i’m using jest for testing, I don’t have access to SessionStorage. Can I mock the sessionStorage to use InMemoryStorage instead?
I tried to inspire myself with your tests, but nothing worked ( I always have ReferenceError: Storage is not defined
)
Thanks for your help
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Testing Python decorators - Medium
Testing decorators is tiny bit different. You need to leave decorated function out of the equation and instead verify whether decorator does ...
Read more >django - Testing Python Decorators? - Stack Overflow
I'm writing some unit tests for a Django project, and I was wondering if its possible (or necessary?) to test some of the...
Read more >How To Test Python Decorators? How To Bypass A Decorator?
Python decorators can be easily tested by integration tests, but it is good practice to create some unit tests for them as well....
Read more >unittest — Unit testing framework — Python 3.11.1 ...
Skipping a test is simply a matter of using the skip() decorator or one of its conditional variants, calling TestCase.skipTest() within a setUp()...
Read more >Things to remember about decorators - James Cooke
When unit testing decorators, one strategy can be to manually call the decorator on a mocked object and inspect how it interacts with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wow, well played, it’s working !
Thanks a lot 😃
PS: I’m using typescript 3.1.3.
I deployed a new version 3.0.0-beta.12 removing the typescript’s Storage interface usage. Can you remove the LOCAL_STORAGE & SESSION_STORAGE overriding from your test file and tell me if it works?
The providers defined in the current module always have the priority over the library ones.