Tell me about your testing experience: unit tests, integration tests, Playwright.
sobes.tech AI
Answer from AI
Unit tests check individual functions or components in isolation, without interaction with external dependencies. They are fast and help identify errors early. For example, in React, you can test individual functions or small components using Jest.
Integration tests verify the interaction of multiple components or modules together, including working with APIs, databases, or other services. They help ensure that parts of the system work correctly together.
Playwright is a tool for end-to-end testing that automates browsers and checks the application's functionality from the user's perspective. It can be used to test scenarios such as registration, login, checkout, and to verify UI and behavior across different browsers.
Example of a unit test in Jest for an addition function:
function sum(a, b) {
return a + b;
}
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
Playwright example for checking page load:
const { test, expect } = require('@playwright/test');
test('homepage has title', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveTitle(/Example Domain/);
});