Using with DynamoDB

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