I'm hiring a unit testing engineer to help write unit tests for our TypeScript project…
- User
I'm hiring a unit testing engineer to help write unit tests for our TypeScript project management web app. Write a simple take-home coding assignment that would test their skills, ideally a task that is related to scientific project management SaaS product.
- Assistant
Here is a simple take-home coding assignment that would test the unit testing skills of a potential hire for a TypeScript project management web app:
Assignment
Your task is to write unit tests for a module that calculates the cost of a scientific project based on the number of researchers and the duration of the project.
The module should have the following function:
codefunction calculateCost(numResearchers: number, numMonths: number): number { return numResearchers * numMonths * 500; }You should write at least 5 unit tests for this function using a testing library of your choice (e.g. Jest, Mocha, etc.). The tests should cover a range of different input scenarios, including valid and invalid input, edge cases, and special cases.
- User
Can you make the function a bit more interesting?
- Assistant
Certainly! Here is a revised version of the take-home coding assignment with a modified
calculateCostfunction that includes additional complexity:Assignment
Your task is to write unit tests for a module that calculates the cost of a scientific project based on the number of researchers, the duration of the project, and the type of research being conducted.
The module should have the following function:
code
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.