Last 12 weeks ยท 1 commit
4 of 6 standards met
For simple use by people unfamiliar with descriptors, but wanting to safely put back the old state after overwriting a property, a simple save and restore might be useful. Two cases where I have wanted to do this are setting an environment variable for a unit test, and hacking to run a unit test. I suspect this is equivalent to is a delete in the first operation to clear the way for whatever I do, and perhaps doesn't make sense as a "mock" pattern. Could be wishful thinking that this might be a possible helper routine. ๐ Edit: a better description of the usage pattern might be "stash" and "restore". e.g.
Repository: ljharb/mock-property. Description: Given an object and a property, replaces a property descriptor (or deletes it), and returns a thunk to restore it. Stars: 7, Forks: 1. Primary language: JavaScript. Languages: JavaScript (100%). License: MIT. Topics: define, delete, descriptor, mock, object, property, test, testing, value. Open PRs: 0, open issues: 1. Last activity: 2mo ago. Community health: 85%. Top contributors: ljharb.