Junior — Middle
What level of test coverage do you use when developing your code?
sobes.tech AI
Answer from AI
The test coverage level depends on the project and requirements, but I usually aim for at least 70-80% coverage of critical modules. For Node.js, it is important to cover business logic and main functions with unit tests, as well as integration tests to verify component interactions. For example, using Jest, you can write tests for functions and APIs:
const sum = (a, b) => a + b;
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
It is not only about the coverage percentage but also about the quality of tests—they should check different scenarios and edge cases.