Testing

Learn how to test your ShipKit application effectively

Testing Your ShipKit Application

ShipKit comes with a comprehensive testing setup that includes both unit and end-to-end testing capabilities.

Testing Stack

Vitest

Fast unit testing with native TypeScript support and Jest compatibility

Playwright

Reliable end-to-end testing for web applications

Unit Testing with Vitest

import { describe, it, expect } from 'vitest'
import { validateEmail } from '@/lib/validations'

describe('validateEmail', () => {
  it('should validate correct email formats', () => {
    expect(validateEmail('[email protected]')).toBe(true)
    expect(validateEmail('invalid-email')).toBe(false)
  })
})

End-to-End Testing with Playwright

import { test, expect } from '@playwright/test'

test('authentication flow', async ({ page }) => {
  await page.goto('/')
  await page.click('text=Sign In')
  await page.fill('[name=email]', '[email protected]')
  await page.fill('[name=password]', 'password123')
  await page.click('text=Submit')
  await expect(page.locator('text=Dashboard')).toBeVisible()
})

Test Coverage

ShipKit is configured to generate test coverage reports using Vitest's built-in coverage reporting:

pnpm test:coverage

Continuous Integration

We recommend setting up GitHub Actions to run your tests automatically:

name: Tests
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: pnpm install
      - run: pnpm test
      - run: pnpm test:e2e

Best Practices

  • Write tests as you develop new features
  • Aim for high test coverage on critical paths
  • Use meaningful test descriptions
  • Keep tests focused and isolated
  • Mock external dependencies appropriately
  • Run the full test suite before deploying