sls-jest
  • Getting Started
  • Core Concepts
  • AWS Credentials
  • Matchers
    • DynamoDB
    • S3
    • AppSync
    • EventBridge
  • Spies
    • Setup
    • EventBridge
  • Utilities
    • DynamoDB
  • Cookbooks
    • Github Actions
    • CDK
Powered by GitBook
On this page
  • toExist()
  • toExistAndMatchObject<E>(expected: DeepPartial<E>)
  • toExistAndMatchSnapshot(propertiesOrHint?: string, hint?: string)
  • toExistAndMatchInlineSnapshot(propertiesOrHint?: string, hint?: string)

Was this helpful?

Edit on GitHub
  1. Matchers

DynamoDB

PreviousAWS CredentialsNextS3

Last updated 2 years ago

Was this helpful?

A collection of matchers that you can use to assert on DynamoDB items.

Use the dynamodbItem() helper function to specify which dynamoDB Item you are testing. It takes the following input parameters:

  • tableName: The table name where the item should be found.

  • key: They key of the item you are looking for

  • retryPolicy: An optional options config. sls-jest will retry using the given retry policy until the test passes or all the retries are exhausted. This is useful in an asynchronous context.

toExist()

Asserts whether a DynamoDB item exists in the given table.

await expect(
  dynamodbItem({
    tableName: 'users',
    key: {
      pk: 'USER#123',
      sk: 'USER#123',
    },
  }),
).toExist();

toExistAndMatchObject<E>(expected: DeepPartial<E>)

await expect(
  dynamodbItem({
    tableName: 'todos',
    key: {
      id: '123',
    },
  }),
).toExistAndMatchObject<Todo>({
  title: 'Buy milk',
});

toExistAndMatchSnapshot(propertiesOrHint?: string, hint?: string)

await expect(
  dynamodbItem({
    tableName: 'todos',
    key: {
      id: '123',
    },
  }),
).toExistAndMatchSnapshot();

toExistAndMatchInlineSnapshot(propertiesOrHint?: string, hint?: string)

await expect(
  dynamodbItem({
    tableName: 'todos',
    key: {
      id: '123',
    },
  }),
).toExistAndMatchInlineSnapshot(`
  Object {
    "id": "123",
    "title": "Buy milk",
  }
`);

Asserts that an item exists in the given table, and matches a subset of the properties of an object. It works similarly to jest's .

Asserts that an item exists in the given table, and that it matches the most recent snapshot. It works similarly to jest's .

Asserts that an item exists in the given table, and that it matches the most recent inline snapshot. It works similarly to jest's .

node-retry
toMatchObject
toMatchSnapshot
toMatchInlineSnapshot