Context proxying doesn't work with Date
See original GitHub issueNot sure the reason, stepped through the code briefly. Something like this doesn’t work:
test('whatever', context => {
let { date } = context;
date.getTime(); // throws.
});
I think getTime()
doesn’t like it when the receiver is a proxy.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Proxy on a date object - javascript - Stack Overflow
My original answer was all wrong. But the following handler should work. const handler = { get: function(target, name) { return name in ......
Read more >Configure your proxy or firewall to enable Microsoft Defender ...
Describes how to set up your firewall or proxy to allow communication between the Microsoft Defender for Identity cloud service and ...
Read more >Set up Lambda proxy integrations in API Gateway
Learn how to configure a Lambda proxy integration request and integration response in API Gateway.
Read more >What is a Proxy Server and How Does it Work? - Varonis
A proxy server acts as a gateway between you and the internet. Learn the basics about proxies with our complete, easy-to-follow guide.
Read more >Configuring Proxies for Tableau Server
Confirm that the proxy settings do not conflict with other Windows proxy configurations. Step 6: Test the proxy configuration. To test the new...
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
Ya I’ll probably have to drop the immutability locker. Was a nice idea but doesn’t seem to be all that viable (sans cloning objects before each test).
If you consider this a must-have, please say so now before it’s too late 😉
@matthewp I wasn’t talking about Object.create in my last comment 😃 Yes it’s a new object, but as demonstrated in my snippet above,
Object.create(context)
doesn’t work because (as you’ve pointed out) thecontext
is mounted as a prototype. Any changes (to existing keys) on theObject.create
would affect the originalcontext
, at which point there’s no immutability protection. That kinda defeats the purpose IMO since the point ofcontext
is to pass around shared values – if those are still vulnerable – and only new keys got washed away after each test – then there’s no real point inObject.create
ing at all. I would be just as well off using local variables inside my test.Creating a new object and then assigning the keys to that object would then be a copy/clone, and that’s where the performance question comes in. This is what
klona
is doing, and while it’s currently the fastest of the deep-cloners, including it in a place likebefore.each
would still have some measurable impact on test runtime. Here’s a hodgepodge of a few different metrics – also included plain object creators (pojo, nCreate, oCreate) just to illustrate the cost between them.