Junior — Middle
Do you perform testing of your code?
sobes.tech AI
Answer from AI
Yes, I always try to test my code to ensure its correctness and prevent errors.
In Node.js, testing frameworks like Jest or Mocha are usually used for this purpose.
Here's a simple test example with Jest:
// sum.js
function sum(a, b) {
return a + b;
}
module.exports = sum;
// sum.test.js
const sum = require('./sum');
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
Testing helps identify bugs early and makes code maintenance easier.