This guide covers Authrim's comprehensive testing strategy including unit tests, integration tests, E2E tests, conformance tests, and load testing.
- Test Overview
- Unit Tests
- Integration Tests
- E2E Tests
- Accessibility Tests
- Performance Tests
- OIDC Conformance Tests
- Load Testing
- CI/CD Integration
- Running All Tests
| Test Type | Tool | Purpose | Location |
|---|---|---|---|
| Unit | Vitest | Backend API, DOs, Components | packages/*/test/ |
| Integration | Vitest | Authorization flows, security | test/integration/ |
| E2E | Playwright | User flows, UI functionality | test-e2e/ |
| Accessibility | axe-core | WCAG 2.1 AA compliance | test-e2e/ |
| Performance | Lighthouse CI | Core Web Vitals | lighthouserc.json |
| Load | k6 | Performance at scale | load-testing/ |
| Conformance | OIDC Foundation | OpenID certification | (separate setup) |
# Run all unit tests
pnpm test
# Run with coverage
pnpm test --coverage
# Run specific package tests
pnpm --filter=@authrim/ar-lib-core test
pnpm --filter=@authrim/ar-token test
# Run in watch mode
pnpm --filter=@authrim/ar-lib-core test -- --watchpackages/
├── ar-lib-core/src/__tests__/
│ ├── durable-objects/ # DO unit tests
│ │ ├── AuthorizationCodeStore.test.ts
│ │ ├── SessionStore.test.ts
│ │ └── RefreshTokenRotator.test.ts
│ └── utils/ # Utility function tests
├── ar-auth/src/__tests__/ # Authorization endpoint tests
├── ar-token/src/__tests__/ # Token endpoint tests
├── ar-userinfo/src/__tests__/ # UserInfo endpoint tests
└── ar-management/src/__tests__/ # Admin API tests
Durable Objects (~50+ tests):
AuthorizationCodeStore: Code issuance, validation, replay preventionSessionStore: Session lifecycle, hot/cold storage, multi-deviceRefreshTokenRotator: Token rotation, theft detection, audit loggingKeyManager: JWK management, key rotation
Handlers (~300+ tests):
- Authorization endpoint flows
- Token endpoint (all grant types)
- UserInfo claims handling
- Client registration
- Token introspection/revocation
# Run integration tests
pnpm test -- --filter=integrationKey Test Suites:
| Suite | Description |
|---|---|
authorization-flow.test.ts |
Complete OAuth 2.0/OIDC flows with PKCE |
durable-objects.test.ts |
Cross-DO communication, state consistency |
security-headers.test.ts |
CSP, HSTS, X-Frame-Options, CORS |
# Run E2E tests
pnpm test:e2e
# Interactive UI mode
pnpm test:e2e:ui
# Headed mode (see browser)
pnpm test:e2e:headed
# Debug mode
pnpm test:e2e:debugFile: playwright.config.ts
- Browser: Chromium (extendable to Firefox, WebKit)
- Base URL:
http://localhost:4173(preview server) - Auto Server: Starts via
webServeroption - Artifacts: Screenshots/videos on failure, traces on retry
test-e2e/
├── homepage.spec.ts # Homepage load, navigation
├── accessibility.spec.ts # WCAG 2.1 AA compliance
└── login.spec.ts # Login flow tests
Standard: WCAG 2.1 Level A & AA
# Run accessibility tests
pnpm test:e2e test-e2e/accessibility.spec.tsCoverage:
- Color contrast (4.5:1 normal, 3:1 large text)
- Keyboard navigation (tab order, focus indicators)
- ARIA attributes validation
- Form labels and associations
# Full Lighthouse CI run
pnpm test:lighthouse
# Collect only
pnpm test:lighthouse:collect
# Assert only
pnpm test:lighthouse:assert| Metric | Target |
|---|---|
| Performance | 90+ |
| Accessibility | 90+ |
| Best Practices | 90+ |
| SEO | 90+ |
| Metric | Target |
|---|---|
| First Contentful Paint (FCP) | < 2000ms |
| Largest Contentful Paint (LCP) | < 2500ms |
| Cumulative Layout Shift (CLS) | < 0.1 |
| Total Blocking Time (TBT) | < 300ms |
Authrim supports running against the OpenID Foundation certification tests.
| Plan | Description | Status |
|---|---|---|
| Basic OP | Standard OIDC Provider | ✓ |
| Config OP | Configuration endpoint | ✓ |
| Dynamic OP | Dynamic client registration | ✓ |
| FAPI 2.0 | Financial-grade API 2.0 | Testing |
- Deploy Authrim to a public endpoint
- Register at OpenID Conformance Suite
- Configure your test plan with your Authrim endpoints
- Run tests through the web interface
See the OpenID Foundation's documentation for detailed instructions.
Test Authrim's performance under realistic load using K6.
Full documentation: See
load-testing/README.mdin the repository root for complete setup and benchmark guides.
cd load-testing
# 1. Seed test data (example: access tokens)
BASE_URL=https://your-authrim.example.com \
CLIENT_ID=xxx CLIENT_SECRET=yyy ADMIN_API_SECRET=zzz \
TOKEN_COUNT=1000 \
node scripts/seeds/seed-access-tokens.js
# 2. Run benchmark
k6 run \
--env BASE_URL=https://your-authrim.example.com \
--env CLIENT_ID=xxx --env CLIENT_SECRET=yyy \
--env PRESET=rps100 \
scripts/benchmarks/test-introspect-benchmark.js| Benchmark | Endpoint | Seed Script |
|---|---|---|
| Token Introspection | POST /introspect |
seed-access-tokens.js |
| Token Exchange | POST /token |
seed-access-tokens.js |
| UserInfo | GET /userinfo |
seed-access-tokens.js |
| Silent Auth | GET /authorize?prompt=none |
seed-otp-users.js |
| Mail OTP Login | 5-step OAuth flow | seed-otp-users.js |
| Passkey Login | 6-step OAuth flow | seed-passkey-users.js |
| Endpoint | Recommended RPS | Peak RPS |
|---|---|---|
| Silent Auth (128 shards) | 2,500 | 3,500 |
| Refresh Token (48 shards) | 2,500 | 3,000 |
| UserInfo | 2,000 | 2,500 |
| Token Introspection (32 shards) | 300 | 500 |
load-testing/scripts/
├── benchmarks/ # K6 benchmark scripts
│ ├── test-introspect-benchmark.js
│ ├── test-userinfo-benchmark.js
│ └── ...
├── seeds/ # Seed data generation
│ ├── seed-access-tokens.js
│ ├── seed-otp-users.js
│ └── ...
└── utils/
└── report-cf-analytics.js # Cloudflare metrics
# Fetch metrics for last 10 minutes
CF_API_TOKEN=xxx node scripts/utils/report-cf-analytics.js --minutes 10
# Fetch metrics for specific time range
CF_API_TOKEN=xxx node scripts/utils/report-cf-analytics.js \
--start "2025-12-17T10:00:00Z" --end "2025-12-17T10:30:00Z"Workflow: .github/workflows/ci.yml
Jobs:
- lint-and-test: Lint, TypeCheck, Unit Tests, Build
- e2e-and-accessibility: E2E tests with accessibility
- lighthouse: Performance tests
# Run before committing
pnpm run lint
pnpm run typecheck
pnpm run format:check# Essential checks before PR
pnpm run lint && pnpm run typecheck && pnpm test# All tests (except load tests)
pnpm test # Unit tests
pnpm test:e2e # E2E + Accessibility
pnpm test:lighthouse # Performance# Run everything
pnpm test && \
pnpm test:e2e && \
pnpm test:lighthouse| Category | Target |
|---|---|
| Unit Test Coverage | 80%+ |
| E2E Coverage | All critical flows |
| Accessibility | 100% WCAG 2.1 AA |
| Performance | 90+ Lighthouse |
# Kill stale processes
pkill -f wrangler
pkill -f playwright# Build UI first
pnpm --filter=ui build
# Then run E2E
pnpm test:e2e