## Problem You have a [[System under test|SUT]] that writes message to an [[AWS SQS|SQS]] queue and you wish to verify this behaviour in an integration test. However, another Lambda function within the same deployed environment is subscribed to that queue so may get the message before your test does. ## Solutions ### Programmatically disable Lambda trigger in setup See [this example](https://harishkm.in/2020/07/18/enable-disable-aws-lambda-triggers-programmatically-by-invoking-an-api/). This could be done in `beforeAll` hook. However, this could be error-prone, especially if running in a long-lived environment where manual testing is also performed. e.g. what happens if the afterAll hook doesn't run correctly to re-enable the trigger? ### Use something else instead of SQS polling to verify correct publishing For example, print a log statement after writing to SQS and have the test case poll [[AWS CloudWatch|CloudWatch]] logs for its presence.