Using with DynamoDB
- First, install
yarn add --dev @shelf/jest-dynamodb
- Specify preset in your Jest configuration:
- Create
jest-dynamodb-config.js
and define DynamoDB tables
module.exports = {
tables: [
{
KeySchema: [{AttributeName: 'id', KeyType: 'HASH'}],
ProvisionedThroughput: {ReadCapacityUnits: 1, WriteCapacityUnits: 1},
},
// etc
],
};
- Configure DynamoDB client
- Write tests
it('should insert item into table', async () => {
.promise();
const {Item} = await ddb.get({TableName: 'files', Key: {id: '1'}}).promise();
expect(Item).toEqual({
id: '1',
hello: 'world',
});