How can I test an AWS lambda that is triggered by a Cognito PostConfirmation event?

Background
I have created a sandbox repo for learning how to work with serverless, AWS Lambda and more. (I used the repo from the serverless tutorial as a starting point.)

In this repo, I have a lambda that is triggered by a Cognito PostConfirmation event.

# serverless config
  createUserSpace:
    handler: api/createUserSpace.main
    environment:
      TABLE_NAME: ${self:custom.userSpacesTableName}
    events:
      - cognitoUserPool:
          pool: logd_${self:custom.stage}_auth_pool
          trigger: PostConfirmation
          existing: true
// the lambda handler
export const main = (event: CognitoUserPoolEvent, context: any) => {

  if (event.request.userAttributes.sub) {
   // call some business logic here
  }
  context.done(null,event);

};

Goal
I would like to write a test that ensure that this lambda handles this event as expected.
Currently I am testing this manually using the CLI commands found in the tutorial.

First:

aws cognito-idp sign-up \
  --region YOUR_COGNITO_REGION \
  --client-id YOUR_COGNITO_APP_CLIENT_ID \
  --username admin@example.com \
  --password Passw0rd!

Then:

 aws cognito-idp admin-confirm-sign-up \
  --region YOUR_COGNITO_REGION \
  --user-pool-id YOUR_COGNITO_USER_POOL_ID \
  --username admin@example.com

How might one replicate this in an automated test?

Or, if not possible, what would a good approach to testing a lambda that is triggered by a Cognito PostConfirmation event?

Any tips or advice would be highly appreciated!