Skip to content

Conversation

@seb-cr
Copy link
Contributor

@seb-cr seb-cr commented Mar 20, 2024

First attempt at adding tests for some of the types used in Lambda Wrapper v2.

In #1196 I tried to fix one problem and inadvertently caused another more serious problem. I caught this during manual QA, but this is precisely why automated tests are so valuable. Some of the type-related features of Lambda Wrapper are complex enough that we should have their behaviour defined in a test suite.

About these tests: they do not "run", as such, and instead the types are checked statically by the TypeScript compiler. All assertions happen at the type system level. Test failures will be flagged by a type error on the failing assertion. I think it still makes sense to organise these tests using describe and it to give structure and context to the assertions.

The docs for expect-type are useful. I tried various packages (ts-expect, tsd) and found expect-type to provide the most expressive API and it doesn't need any particular setup.

So far I've written tests for only di.get and SQSService, as this covers most of the interesting stuff and is where I've been seeing problems – there's enough here to fail following the changes in #1196. It would also be good to cover things relating to Lambda Wrapper configuration, however this was not as straightforward as I hoped so I'm leaving it for now.

Jira: ENG-3188

@seb-cr seb-cr requested a review from corinja March 20, 2024 16:49
Copy link
Member

@corinja corinja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good. It will probably take me actually using it in some development using the Lambda Wrapper to really get the benefits but I think it looks good.

@seb-cr seb-cr merged commit b42e74f into beta Mar 25, 2024
@seb-cr seb-cr deleted the ENG-3188/test-types branch March 25, 2024 16:58
@seb-cr seb-cr mentioned this pull request Mar 26, 2024
@github-actions
Copy link

🎉 This PR is included in version 2.0.0-beta.16 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants