aws-testing-library icon indicating copy to clipboard operation
aws-testing-library copied to clipboard

fix: not.toHaveLog no longer returns a false pass when waiting for Cl…

Open danemauland opened this issue 3 years ago • 3 comments

Calling expect(options).not.toHaveLog(expectedLog) when the logs contain expectedLog would incorrectly pass. This happens when logs generated previously in the tests don't propagate to CloudWatch in time for the toHaveLog matcher to catch it.

To fix this, I added a new util, wrapWithRetryUntilPass, that will continue to query until the log is found or until the test times out.

danemauland avatar Apr 07 '22 22:04 danemauland

Pull Request Test Coverage Report for Build 2111831727

  • 0 of 11 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 99.73%

Totals Coverage Status
Change from base Build 2086947220: 0.005%
Covered Lines: 615
Relevant Lines: 615

💛 - Coveralls

coveralls avatar Apr 11 '22 07:04 coveralls

Pull Request Test Coverage Report for Build 3297002803

  • 11 of 11 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 99.731%

Totals Coverage Status
Change from base Build 3296984775: 0.005%
Covered Lines: 617
Relevant Lines: 617

💛 - Coveralls

coveralls avatar Apr 11 '22 07:04 coveralls

I've got exactly that issue. I test my EventBridge integration and there are normally two common patterns:

flag: true -> EB should consume event

flag: false -> EB shouldn't get event

It would be nice to test both. But every time I use expect().not.toHaveLog() it passes.

AlessandroVol23 avatar Sep 01 '22 11:09 AlessandroVol23