Junior — Middle
What types of tests have you created and used in your projects?
sobes.tech AI
Answer from AI
In Node.js projects, I have created and used several types of tests:
- Unit tests — test individual functions or modules in isolation. For example, testing a data processing function.
- Integration tests — test the interaction between modules or with external services, such as database operations.
- E2E (end-to-end) tests — test the entire application, simulating user actions.
Here's a simple example of a unit test using Jest:
const sum = (a, b) => a + b;
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});