object-crumble
v0.6.6
Published
Creative ways to cook your object
Downloads
6
Maintainers
Readme
Object-crumble
Creative ways to cook your objects
The main motivation is to boost the writing of unit tests by simplifying the process of creating new data content. This is achieved by mutating programmatically existing data:
Written in
Typescript
.Uses JSON-like object as an input.
Can be used with any testing framework (Jest, ...)
A simpler and experimental alternative to property testing. No need for a schema. You should still consider, property based testing framework likefast-check that can help find bugs in unexplored code paths.
Usage
Convert any object to an abstract representation of the object structure
abstractObject({name: "Jane", homepage: "http://mywebsite.com" })
will return:
[
{
path: "name",
kind: "string",
},
{
path: "homepage",
kind: "url",
},
];
Mutates an object applying a mutation.
const mutation = {
path: "name",
kind: "string",
mutationName: "string => empty",
};
mutateObject(mutatorRules)(mutation)({
name: "Picasso",
firstName: "Pablo",
});
will return empty field for name
:
{
name: '',
firstName: 'Pablo'
}
A more exhaustive documentation of the api is available
Documentation and links
- Code Maintenance
- Code Of Conduct
- Api for object-crumble
- Contributing
- Glossary
- Diagram for the code base
- Vocabulary used in the code base
- Architectural Decision Records
- Contributors
- Dependencies
Installation
This package is ESM only.
yarn add object-crumble