Security News
Internet Archive Hacked, 31 Million Record Compromised
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
A factory framework for mock test objects in JavaScript. Will generate objects, models, and scenarios for tests.
Unionized is a factory library for setting up JavaScript objects as test data. Compare to the factory_girl Ruby gem by thoughtbot.
Define a factory:
var humanFactory = unionized.factory({
name: {
first: unionized.enum(['Azrael', 'Bastiaan', 'Laurentiu', 'Gerolf']),
last: 'Smithy'
},
birthdate: function() { return new Date() }
})
Use that factory to create instances:
var human = humanFactory.create()
/*
{ name: { first: 'Gerolf', last: 'Smithy' }
birthdate: Sun May 17 2015 16:52:25 GMT-0700 (PDT) }
*/
You can override the defaults if you like, using dot notation:
var chen = humanFactory.create({ 'name.first': 'Chen' })
/*
{ name: { first: 'Chen', last: 'Smithy' }
birthdate: Sun May 17 2015 16:58:19 GMT-0700 (PDT) }
*/
You might want factories that are composed out of other factories:
var organizationFactory = unionized.factory({
name: 'Board Game Club',
members: unionized.array(humanFactory, 4)
})
organizationFactory.create()
/*
{ name: 'Board Game Club',
members: [
{ name: { first: 'Bastiaan', last: 'Smithy' },
birthdate: Sun May 17 2015 17:09:52 GMT-0700 (PDT) },
{ name: { first: 'Azrael', last: 'Smithy' },
birthdate: Sun May 17 2015 17:09:52 GMT-0700 (PDT) }
{ name: { first: 'Gerolf', last: 'Smithy' },
birthdate: Sun May 17 2015 17:09:52 GMT-0700 (PDT) }
{ name: { first: 'Bastiaan', last: 'Smithy' },
birthdate: Sun May 17 2015 17:09:52 GMT-0700 (PDT) }
] }
*/
You might want to pass arguments into your factory definitions:
var humanFactoryWithAge = humanFactory.factory (age) => {
birthDate: moment().subtract(age, 'years').toDate()
};
var legalDriver = humanFactoryWithAge.create({}, 16);
/*
{ name: { first: 'Azrael', last: 'Smithy' }
birthdate: Sun May 17 2000 15:00:02 GMT-0700 (PDT) }
*/
More features you may be interested in:
FAQs
A factory framework for mock test objects in JavaScript. Will generate objects, models, and scenarios for tests.
The npm package unionized receives a total of 11 weekly downloads. As such, unionized popularity was classified as not popular.
We found that unionized demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
Security News
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
Security News
Our threat research team breaks down two malicious npm packages designed to exploit developer trust, steal your data, and destroy data on your machine.