/** * 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; tournamentTeamCount?: number; 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; tournamentTeamCount?: number; 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();