awslabs / awslabs/aws-lambda-invoke-store

Expose Test Reset Function

Open
#21 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
9
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Our library can run both inside and outisde the InvokeStore async context. As such, I have suites of concurrency tests to verify theconcurrency behiours I expect to see. After the change in `v0.2.x` to change the instantiation logic, ie., the introduction of `getInstanceAsync` this has made testing much more difficult.

This is because the new `_testing` field is only added if the `AWS_LAMBDA_BENCHMARK_MODE` is set to 1 at the very first time the module is imported. This means that if `InvokeStore` is imported at the top level anywhere before your test, i.e., in application code, then the `_testing.reset` [function](https://github.com/awslabs/aws-lambda-invoke-store/blob/db30e3f22032026fa9e79bfd019d7842543e7ec9/src/invoke-store.ts#L186) will not be there. Using `vi.strubEnv` in a `before` block will not work because it is too late, the module has long been imported before then.

I propose that this `reset` function should always be available without the need for `AWS_LAMBDA_BENCHMARK_MODE` to allow for ease of testing for codebases that need to support both environments where `InvokeStore` needs to be use to manage async contexts and where it does not

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.