documentclient-mock v0.3.0
documentclient-mock
documentclient-mock is a mock implementation of AWS.DynamoDB.DocumentClient. While it is a work in progress, it has many of the main features of DocumentClient implemented and operates all in memory. It even includes expression evaluators for condition expressions and update expressions. The main purpose is to allow you to create databases in memory to test business logic against them.
Installation
npm install --save-dev documentclient-mockUsage
const documentClient = require('documentclient-mock');
const client = documentClient({
defns: {
TestTable: {
keySchema: [
{
keyType: 'HASH',
attributeName: 'partitionKey'
}
],
attributeDefinitions: [
{
attributeName: 'partitionKey',
attributeType: 'S'
}
]
}
},
tables: {
TestTable: {
test: {
partitionKey: 'test'
}
}
}
});
client.get({
TableName: 'TestTable',
Key: { partitionKey: 'test' }
}).promise().then(doc => {
console.log(doc);
});documentClient has three options in its parameter:
defns- a hash of table name to table definitiontables- a hash of table name to partitionsfn- a function wrapper for client methods. example jest.fn
Contributing
Contributions are welcomed as not all of the functionality is implemented yet.
There is some low hanging fruit with TODOs sprinkled throughout the code.
If a new feature is implemented or a change is made please add a corresponding test.
Also please ensure all lint checks and tests pass.
Versioning
All patch versions are computed from previous tags on the master branch.
To bump a version please increment the major or minor version in package.json before making the pull request.