Package Exports
- whatever.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (whatever.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
whatever.js
This library lets you define objects that dynamically define properties as you try to access them (using ES6 Proxies). Its main use case is tests where you want to mock services without going to the trouble of setting up objects with the correct schema.
For example, instead of this...
stub(service).return({
user: {
firstName: 'joe',
lastName: 'schmoe',
email: 'joe.schmoe@example.com'
},
items: [
{ id: 1, type: 'woozle', name: 'foo' },
{ id: 2, type: 'wuzzle', name: 'bar' }
],
summary: {
user: 'joe schmoe <joe.schmoe@example.com>',
woozles: 1,
wuzzles: 1
}
});...with whatever.js you can just go with this:
var whatever = require('whatever.js');
stub(service).return(whatever());You can also specify defaults for only the properties you care about (e.g., for testing). Accesses to any other properties of the resulting object will just silently do nothing.
stub(service).return(whatever({
user: {
firstName: 'Billy'
}
}));
assert.equal(greetUser(), 'Hello, Billy');