fix: update Cucumber config and hooks to properly load test infrastructure
- Add support files to require config for proper hook loading - Remove database cleanup from hooks (browser-only testing) - Fix World type issues in hooks - Cucumber tests now run successfully
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
* Cucumber hooks for EuchreCamp E2E tests
|
||||
*/
|
||||
|
||||
import { Before, After, BeforeAll, AfterAll, IWorldOptions, World } from '@cucumber/cucumber';
|
||||
import { chromium, Browser, type FullConfig } from '@playwright/test';
|
||||
import { cleanupAllTestData } from '@/__tests__/test-utils';
|
||||
import { Before, After, BeforeAll, AfterAll } from '@cucumber/cucumber';
|
||||
import { chromium, Browser } from '@playwright/test';
|
||||
import { world } from './world';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
@@ -48,7 +47,7 @@ AfterAll(async function () {
|
||||
/**
|
||||
* Before each scenario: Create new page context
|
||||
*/
|
||||
Before(async function (this: World) {
|
||||
Before(async function () {
|
||||
// Create new context and page
|
||||
world.context = await browser.newContext();
|
||||
world.page = await world.context.newPage();
|
||||
@@ -69,9 +68,9 @@ Before(async function (this: World) {
|
||||
});
|
||||
|
||||
/**
|
||||
* After each scenario: Close page and cleanup test data
|
||||
* After each scenario: Close page
|
||||
*/
|
||||
After(async function (this: World) {
|
||||
After(async function () {
|
||||
console.log('🌍 Cleaning up after scenario...');
|
||||
|
||||
// Close page and context
|
||||
@@ -81,39 +80,29 @@ After(async function (this: World) {
|
||||
if (world.context) {
|
||||
await world.context.close();
|
||||
}
|
||||
|
||||
// Clean up test data
|
||||
try {
|
||||
await cleanupAllTestData();
|
||||
console.log('🌍 Test data cleaned up');
|
||||
} catch (error) {
|
||||
console.error('🌍 Error cleaning up test data:', error);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Custom hook for navigating to a page
|
||||
*/
|
||||
Before({ tags: '@navigation' }, async function (this: World) {
|
||||
Before({ tags: '@navigation' }, async function () {
|
||||
console.log('🌍 Navigation hook triggered');
|
||||
});
|
||||
|
||||
/**
|
||||
* Custom hook for authenticated scenarios
|
||||
*/
|
||||
Before({ tags: '@authenticated' }, async function (this: World) {
|
||||
Before({ tags: '@authenticated' }, async function () {
|
||||
console.log('🌍 Authenticated hook triggered');
|
||||
// This hook can be extended to load saved auth state
|
||||
});
|
||||
|
||||
/**
|
||||
* Tag hooks for specific scenarios
|
||||
*/
|
||||
Before({ tags: '@slow' }, async function (this: World) {
|
||||
Before({ tags: '@slow' }, async function () {
|
||||
console.log('🌍 Slow test - extending timeout');
|
||||
// Note: Timeout extension happens at step definition level
|
||||
});
|
||||
|
||||
Before({ tags: '@flaky' }, async function (this: World) {
|
||||
Before({ tags: '@flaky' }, async function () {
|
||||
console.log('🌍 Flaky test - retry enabled');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user