# Instructions - Following Playwright test failed. - Explain why, be concise, respect Playwright best practices. - Provide a snippet of code with the fix, if possible. # Test info - Name: tssc/full_workflow.test.ts >> TSSC Complete Workflow >> Component Creation >> should create a component successfully - Location: tests/tssc/full_workflow.test.ts:45:5 # Error details ``` Error: No testItem found in test configuration. Check your playwright.config.ts setup. ``` # Test source ```ts 1 | import { TestItem } from '../../playwright/testItem'; 2 | import { test as base, TestInfo } from '@playwright/test'; 3 | import { testContextStorage, extractTestContext } from '../../logger/context/testContext'; 4 | import { LoggerFactory } from '../../logger/logger'; 5 | import type { Logger } from '../../logger/logger'; 6 | 7 | /** 8 | * Type definition for the TSSC test fixtures 9 | */ 10 | export type RhtapTestFixture = { 11 | testItem: TestItem; 12 | autoTestContext: void; // Auto-fixture for logger context 13 | logger: Logger; // Logger with test context pre-configured (supports parameterized logging) 14 | }; 15 | 16 | /** 17 | * Extracts the TestItem from the test configuration 18 | * @param testInfo Playwright test info object 19 | * @returns The TestItem from the test configuration or throws an error if not found 20 | */ 21 | export function getDynamicTestItem(testInfo: any): TestItem { 22 | const testItemFromConfig = testInfo?.project?.use?.testItem as TestItem; 23 | if (!testItemFromConfig) { > 24 | throw new Error( | ^ Error: No testItem found in test configuration. Check your playwright.config.ts setup. 25 | 'No testItem found in test configuration. Check your playwright.config.ts setup.' 26 | ); 27 | } 28 | return testItemFromConfig; 29 | } 30 | 31 | /** 32 | * Creates a basic TSSC test fixture with the TestItem and auto-logger context 33 | */ 34 | export const createBasicFixture = () => { 35 | return base.extend({ 36 | testItem: async ({}, use, testInfo) => { 37 | const testItem = getDynamicTestItem(testInfo); 38 | await use(testItem); 39 | }, 40 | // Logger fixture with test context pre-configured 41 | logger: async ({}, use, testInfo: TestInfo) => { 42 | const testContext = extractTestContext(testInfo); 43 | // Extract test file name without extension (e.g., "full_workflow" from "full_workflow.test.ts") 44 | const testFileName = testInfo.file.split('/').pop()?.replace(/\.test\.ts$/, '') || 'test'; 45 | 46 | // Use just the test file name as logger name 47 | // Project info is already available in metadata (projectName, worker) 48 | const loggerName = testFileName; 49 | 50 | const logger = LoggerFactory.getLogger(loggerName, testContext); 51 | await use(logger); 52 | }, 53 | // Auto-fixture for logger context (runs automatically before every test) 54 | autoTestContext: [ 55 | async ({}, use, testInfo: TestInfo) => { 56 | const testContext = extractTestContext(testInfo); 57 | 58 | // Set global context as fallback for AsyncLocalStorage 59 | // This ensures context propagates across all async boundaries 60 | const { contextManager } = require('../../logger/context/contextManager'); 61 | contextManager.setContext(testContext); 62 | 63 | try { 64 | // Run test within AsyncLocalStorage context 65 | // All logger calls within this test will automatically include test context 66 | await testContextStorage.run(testContext, async () => { 67 | await use(); 68 | }); 69 | } finally { 70 | // Clean up global context after test 71 | contextManager.clearContext(); 72 | } 73 | }, 74 | { auto: true }, // Automatically runs for every test 75 | ], 76 | }); 77 | }; 78 | ```