How to implement test timeout for playwright in a BDD Cucumber framework written in Typescript?

89 Views Asked by At

I am working on creating a full fledged test automation framework using playwright which will have the options of both TDD and BDD. For implementing the TDD part I am using playwright test runner, but the playwright documentation does not seem to contain anything on how it can be integrated with BDD.

However, I have created the BDD structure and am able to run playwright tests. The issue I am facing currently is that the timeout mentioned in the playwright.config.ts is not working in BDD and often tests are failing when the default timeout of 5000ms is exceeded. The error stacktrace is as follows:

× When User launches Youtube # BDD\Steps\YoutubeSteps.ts:5
       Error: function timed out, ensure the promise resolves within 5000 milliseconds
           at Timeout.<anonymous> (D:\TestAutomationFrameworks\PlaywrightTs\node_modules\@cucumber\cucumber\src\time.ts:52:14)
           at listOnTimeout (node:internal/timers:573:17)
           at processTimers (node:internal/timers:514:7)

I tried searching the documentation here but couldn't find anything related to BDD

I have tried including the playwright.config.ts in my cucumber.json require block:

{
    "default": {
        "paths": [
            "./BDD/Features/*.feature"
        ],
        "require": [
            "./BDD/Steps/*.ts",
            "./BDD/Hooks/Hooks.ts",
            "./playwright.config.ts"
        ],
        "requireModule": ["ts-node/register"],
        "forceExit": true
    }
}

The timeout is mentioned in my playwright.config.ts as below:

const config: PlaywrightTestConfig = {
  use: {
    headless:Config.headless,
    video:{
      mode:'on'
    },
    viewport:null
  },
  outputDir:'./TestResults',
  timeout:120000,
  fullyParallel:true,
  reporter:[['junit',{outputFile:'./TestResults/TestResults.xml'}]]
};

Note: Timeout is working well and good while using the playwright test runner in tdd.

0

There are 0 best solutions below