Unit Test vs Integration Test
Unit tests versus integration tests: scope, speed, reliability, ROI, and how to balance the testing pyramid for production-grade applications.
Microsoft's cross-browser, multi-language E2E test engine
An in-browser JS/TS E2E tool focused on developer experience
There's no single right answer, but there is a clear framework. If you need multi-browser coverage, free parallelism, cross-origin/iframe flows, or languages other than JS/TS, Playwright is the default choice in 2026. If you have a large, healthy Cypress suite and an existing Cloud investment, a "tool difference" alone doesn't justify a rewrite — Cypress is more mature in component testing today. A gradual, critical-flow-first migration is more rational than a "weekend rewrite."
| Category | Playwright | Cypress |
|---|---|---|
| Performance | 8/10 | 7/10 |
| Ease of Learning | 7/10 | 8/10 |
| Ecosystem | 8/10 | 7/10 |
| Community | 8/10 | 7/10 |
| Job Market | 7/10 | 7/10 |
| Future-Proof | 9/10 | 6/10 |
// Playwright Test - Login flow and API mock (TypeScript)
import { test, expect } from '@playwright/test';
test.describe('Giris akisi', () => {
test('gecerli kullanici ile giris yapar ve dashboard gorur', async ({ page }) => {
// Network mock - no extra configuration needed
await page.route('**/api/login', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ token: 'test-token', user: { name: 'Ayse' } }),
});
});
await page.goto('/login');
await page.getByLabel('E-posta').fill('[email protected]');
await page.getByLabel('Sifre').fill('guclu-sifre-123');
await page.getByRole('button', { name: 'Giris Yap' }).click();
// Auto-wait: locator waits until visible
await expect(page.getByText('Hos geldin, Ayse')).toBeVisible();
await expect(page).toHaveURL('/dashboard');
});
test('checkout iframe icindeki odeme butonunu bulur (cross-frame)', async ({ page }) => {
await page.goto('/checkout');
// v1.63.0: selector-less frameLocator searches the entire sub-frame tree
const payButton = page.frameLocator().getByRole('button', { name: 'Ode' });
await payButton.click();
await expect(page.getByText('Odeme basarili')).toBeVisible();
});
});
test('3 tarayicida paralel calisir (playwright.config.ts icinde tanimli)', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/Ana Sayfa/);
});// Cypress - Login flow and API mock (JavaScript/TypeScript)
describe('Giris akisi', () => {
it('gecerli kullanici ile giris yapar ve dashboard gorur', () => {
// Network stub with cy.intercept
cy.intercept('POST', '/api/login', {
statusCode: 200,
body: { token: 'test-token', user: { name: 'Ayse' } },
}).as('loginRequest');
cy.visit('/login');
cy.get('[data-cy=email]').type('[email protected]');
cy.get('[data-cy=password]').type('guclu-sifre-123');
cy.get('[data-cy=submit]').click();
cy.wait('@loginRequest');
// Cypress auto-retry: waits until the element is visible
cy.contains('Hos geldin, Ayse').should('be.visible');
cy.url().should('include', '/dashboard');
});
it('cross-origin odeme sayfasina yonlenir (cy.origin gerekli)', () => {
cy.visit('/checkout');
cy.get('[data-cy=pay-button]').click();
// cy.origin() is required when switching to a different origin
cy.origin('https://pay.example.com', () => {
cy.get('[data-cy=confirm-payment]').click();
cy.contains('Odeme onaylandi').should('be.visible');
});
});
});
// cypress.config.js — basic E2E configuration
module.exports = {
e2e: {
baseUrl: 'http://localhost:3000',
experimentalRunAllSpecs: true,
setupNodeEvents(on, config) {
return config;
},
},
};There's no single right answer, but there is a clear framework. If you need multi-browser coverage, free parallelism, cross-origin/iframe flows, or languages other than JS/TS, Playwright is the default choice in 2026. If you have a large, healthy Cypress suite and an existing Cloud investment, a "tool difference" alone doesn't justify a rewrite — Cypress is more mature in component testing today. A gradual, critical-flow-first migration is more rational than a "weekend rewrite."
Get Free ConsultationIf you need multi-browser support (Chromium+Firefox+WebKit), want free built-in parallelism, or need language flexibility across TS/Python/Java/.NET, Playwright is the default choice in 2026. If you already have a large Cypress suite, your team is used to the interactive runner, and you've already invested in Cypress Cloud, switching for "tool difference" alone isn't justified — a gradual migration is more rational.