Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cleanup: Split tests into unit, integ, e2e + additional mocking #369

Closed
wants to merge 15 commits into from

Conversation

andysmith415
Copy link
Collaborator

@andysmith415 andysmith415 commented Mar 3, 2024

  • Split tests into three buckets: unit (no external dependencies), integration (DDB), end-to-end (going through API Gateway)
  • Add a --watch script for unit tests
  • Nix the network-requests file; it's unused as it stands and we can always bring it back.
  • Create a global mock of aws-embedded-metrics. This can be overwritten on a per-test basis as needed.

Main motivation here is to get the unit tests running more quickly and to get to the bottom of some of the suppressions across the testing codebase, notably the es-lint/ts disable checks as well as the need to have --detectOpenHandles and --forceExits enabled. The latter is indicative of an unresolved promise firing after the test completes, so something to figure out.

The check-order-status tests have some dangling promises that are prevently clean exits. Until those are addressed, they can live in integ/ where --forceExits is used.

Goal of this break-out is to be able to separate unit / integration / end-to-end tests. An e2e test is defined as going through the API gateway. We want to get the unit tests running quicker for future work.
Move all handlers / repositories over there. Can move them back gradually in debugging the open handles.
The success cases are all taking 1+ second, so something is systemically
wrong there. Until that is debugged, move them out.
This can be overwritten on a per-test basis as needed. The default metricsScope has a fair amount of environment manipulation when it flushes (https://github.com/awslabs/aws-embedded-metrics-node/blob/master/src/logger/MetricsLogger.ts#L42) which was making the handler tests take one second.
The aws-embedded-metrics mock sped this up.
@andysmith415 andysmith415 changed the title Split tests into unit, integ, e2e Test cleanup: Split tests into unit, integ, e2e + additional mocking Mar 3, 2024
__mocks__/aws-embedded-metrics.ts Show resolved Hide resolved
* Refactor: Drop BaseInjector

* Drop base lambda handler

* Drop BaseHandleRequestParams

No longer used.

* Rename base.ts to ErrorCode.ts since it's the only file left.

* Silo handler functions (#371)

Move entrypoints for each lambda to individual files
@andysmith415
Copy link
Collaborator Author

@robert-seitz-uniswap landed this as part of #376

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants