496541b144
- Install @cucumber/cucumber and cucumber-pretty dependencies - Create Cucumber configuration with tsx loader for TypeScript support - Add step definitions for common navigation, form interactions, and assertions - Add authentication step definitions for login/logout flows - Create feature files for user registration and authentication - Support multiple auth contexts (player, tournament admin, club admin) - Configure package.json scripts for running Cucumber tests Key features: - Gherkin syntax (Given/When/Then) for behavior-driven testing - Browser-only interactions (no direct database access) - Dev site testing (tests run against running dev server) - Happy path focus for acceptance testing - Integration with existing TypeScript project
54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
/**
|
|
* World context for Cucumber tests
|
|
* Provides shared state between step definitions
|
|
*/
|
|
|
|
import { Page, BrowserContext, chromium, Browser } from '@playwright/test';
|
|
|
|
export interface WorldState {
|
|
page: Page;
|
|
context: BrowserContext;
|
|
prisma: any; // Lazy-loaded PrismaClient
|
|
baseURL: string;
|
|
user?: {
|
|
email: string;
|
|
name: string;
|
|
password: string;
|
|
};
|
|
tournament?: any;
|
|
player?: any;
|
|
match?: any;
|
|
}
|
|
|
|
export class World implements WorldState {
|
|
page!: Page;
|
|
context!: BrowserContext;
|
|
prisma: any;
|
|
baseURL: string;
|
|
user?: {
|
|
email: string;
|
|
name: string;
|
|
password: string;
|
|
};
|
|
tournament?: any;
|
|
player?: any;
|
|
match?: any;
|
|
|
|
constructor() {
|
|
this.baseURL = process.env.BASE_URL || 'http://localhost:3000';
|
|
this.prisma = null; // Will be lazily loaded when needed
|
|
}
|
|
|
|
async getPrisma() {
|
|
if (!this.prisma) {
|
|
// Lazily load PrismaClient when first accessed
|
|
const { PrismaClient } = await import('@prisma/client');
|
|
this.prisma = new PrismaClient();
|
|
}
|
|
return this.prisma;
|
|
}
|
|
}
|
|
|
|
// Export singleton instance
|
|
export const world = new World();
|