© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
D. IrvineBuild Your Own Test Frameworkhttps://doi.org/10.1007/978-1-4842-9247-1_4

4. Promoting Conciseness with Shared Setup and Teardown

Daniel Irvine1  
(1)
London, UK
 

Our concise-test automated test framework is starting to take shape. We’ve already got something that’s usable: we can use the it function to write test cases and the describe function to group them.

We don’t yet have any mechanism for dealing with duplication between tests. And we do have some duplication in our own sample application. In test/tests.mjs, for example, three of our tests start in the exact same way, with these three lines:
const repository = new TodoRepository();
const newTodo ...

Get Build Your Own Test Framework: A Practical Guide to Writing Better Automated Tests now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.