Loading
Current section: Test Structure 6 exercises
Problem

Move Tests into Modules

Transcript

00:00 Right now, we keep the test cases for our functions collocated next to the source code. This is called an in-source testing and can be really handy when testing small unit functions like this. But it's a far more resilient approach to move the test cases into a separate module. This will allow you to keep the source code clean, but also help you maintain, change, edit,

00:19 and delete the test files if you need to. So in this exercise, your task would be to take the existing tests and move them into a separate module called greet.test.ts. Once you do that, you would also want to make the functions expect and test available globally, both type-wise and runtime-wise, and put them

00:38 in a file called setup.ts. So then when running tests, you can point to that setup file by using the --import flag, point to the setup, and then the greet.test.ts file to run. I know this is going to be a little tricky, but you can manage it. So give it your best, and see you on the other side.