test: update Cucumber configuration and support files
This commit is contained in:
@@ -40,4 +40,7 @@ module.exports = {
|
|||||||
|
|
||||||
// Strict mode (fail on undefined steps)
|
// Strict mode (fail on undefined steps)
|
||||||
strict: true,
|
strict: true,
|
||||||
|
|
||||||
|
// Increase default timeout for steps (default is 5000ms)
|
||||||
|
defaultTimeout: 30000,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,12 +2,15 @@
|
|||||||
* Cucumber hooks for EuchreCamp E2E tests
|
* Cucumber hooks for EuchreCamp E2E tests
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Before, After, BeforeAll, AfterAll } from '@cucumber/cucumber';
|
import { Before, After, BeforeAll, AfterAll, setDefaultTimeout } from '@cucumber/cucumber';
|
||||||
import { chromium, Browser } from '@playwright/test';
|
import { chromium, Browser } from '@playwright/test';
|
||||||
import { world } from './world';
|
import { world } from './world';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
|
// Set default timeout for Cucumber steps (30 seconds)
|
||||||
|
setDefaultTimeout(30000);
|
||||||
|
|
||||||
// Global browser instance
|
// Global browser instance
|
||||||
let browser: Browser;
|
let browser: Browser;
|
||||||
|
|
||||||
@@ -101,9 +104,7 @@ Before(async function () {
|
|||||||
|
|
||||||
// Log console messages for debugging
|
// Log console messages for debugging
|
||||||
world.page.on('console', msg => {
|
world.page.on('console', msg => {
|
||||||
if (msg.type() === 'error') {
|
console.log(`🌍 BROWSER ${msg.type()}:`, msg.text());
|
||||||
console.log('❌ PAGE ERROR:', msg.text());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Log network errors
|
// Log network errors
|
||||||
|
|||||||
@@ -18,7 +18,12 @@ export interface WorldState {
|
|||||||
tournament?: any;
|
tournament?: any;
|
||||||
tournamentTeamCount?: number;
|
tournamentTeamCount?: number;
|
||||||
player?: any;
|
player?: any;
|
||||||
|
playerId?: string; // Added for storing extracted player ID
|
||||||
match?: any;
|
match?: any;
|
||||||
|
generatedData?: {
|
||||||
|
uniqueEmail?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export class World implements WorldState {
|
export class World implements WorldState {
|
||||||
@@ -34,7 +39,12 @@ export class World implements WorldState {
|
|||||||
tournament?: any;
|
tournament?: any;
|
||||||
tournamentTeamCount?: number;
|
tournamentTeamCount?: number;
|
||||||
player?: any;
|
player?: any;
|
||||||
|
playerId?: string; // Added for storing extracted player ID
|
||||||
match?: any;
|
match?: any;
|
||||||
|
generatedData?: {
|
||||||
|
uniqueEmail?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.baseURL = process.env.BASE_URL || 'http://localhost:3000';
|
this.baseURL = process.env.BASE_URL || 'http://localhost:3000';
|
||||||
@@ -43,9 +53,21 @@ export class World implements WorldState {
|
|||||||
|
|
||||||
async getPrisma() {
|
async getPrisma() {
|
||||||
if (!this.prisma) {
|
if (!this.prisma) {
|
||||||
// Lazily load PrismaClient when first accessed
|
// Load .env.development file for test database configuration (fallback)
|
||||||
|
require('dotenv').config({ path: '.env.development' })
|
||||||
|
|
||||||
|
// Ensure database environment is set for Cucumber tests BEFORE importing PrismaClient
|
||||||
|
if (!process.env.DATABASE_URL) {
|
||||||
|
throw new Error('DATABASE_URL not set. Make sure .env.development exists and contains DATABASE_URL or set DATABASE_URL environment variable.');
|
||||||
|
}
|
||||||
|
process.env.DATABASE_PROVIDER = process.env.DATABASE_PROVIDER || 'postgresql';
|
||||||
|
|
||||||
|
// Import PrismaClient AFTER setting environment variables
|
||||||
const { PrismaClient } = await import('@prisma/client');
|
const { PrismaClient } = await import('@prisma/client');
|
||||||
this.prisma = new PrismaClient();
|
const { PrismaPg } = await import('@prisma/adapter-pg');
|
||||||
|
|
||||||
|
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
|
||||||
|
this.prisma = new PrismaClient({ adapter });
|
||||||
}
|
}
|
||||||
return this.prisma;
|
return this.prisma;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user