Skip to content

Test in verbose mode fails when custom's helper method _beforeSuite/_afteSuite calls an internal helper method #3881

@mirao

Description

@mirao

It's a regression in 3.5.5. It works well with 3.5.4
I guess it's related to the new feature #3858

What are you trying to achieve?

The test should pass in --debug and in --verbose mode

What do you get instead?

The test passes in --debug mode, but fails in --verbose mode

Provide console output if related. Use --verbose mode for more details.

~/workspace/codeceptjs/tests/my$ codeceptjs run My_test.ts --verbose

 Environment information:-

codeceptVersion:  "3.5.5"
nodeInfo:  18.15.0
osInfo:  Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
cpuInfo:  (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
chromeInfo:  117.0.5938.62
edgeInfo:  "N/A"
firefoxInfo:  117.0.1
safariInfo:  N/A
helpers:  {
 "Playwright": {
  "browser": "chromium",
  "url": "http://localhost",
  "show": true
 },
 "MyHelper": {
  "require": "./myhelper_helper.ts"
 }
}
plugins:  {
 "screenshotOnFail": {
  "enabled": true
 }
}
***************************************
If you have questions ask them in our Slack: http://bit.ly/chat-codeceptjs
Or ask them on our discussion board: https://codecept.discourse.group/
Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues
***************************************
CodeceptJS v3.5.5 #StandWithUkraine
Using test root "/home/mirao/workspace/codeceptjs/tests/my"

My --
  ✖ "before all" hook: codeceptjs.beforeSuite for "test something" in 349ms
TypeError: Cannot read properties of undefined (reading 'close')

-- FAILURES:

  1) My
       "before all" hook: codeceptjs.beforeSuite for "test something":
     Cannot read properties of undefined (reading 'close')
      at Playwright._stopBrowser (/home/mirao/workspace/codeceptjs/node_modules/.pnpm/[email protected]_e6w65ce3sp4lg2q5fzcoe2hnqu/node_modules/codeceptjs/lib/helper/Playwright.js:833:24)
      at Playwright.restartBrowser (/home/mirao/workspace/codeceptjs/node_modules/.pnpm/[email protected]_e6w65ce3sp4lg2q5fzcoe2hnqu/node_modules/codeceptjs/lib/helper/Playwright.js:1043:16)
      at MyHelper._beforeSuite (myhelper_helper.ts:5:39)
  
  


  FAIL  | 0 passed, 1 failed   // 356ms
Run with --verbose flag to see complete NodeJS stacktrace

Provide test source code if related

My_test.ts

Feature("My");

Scenario("test something", () => {});

myhelper_helper.ts

import Helper from "@codeceptjs/helper";

class MyHelper extends Helper {
    async _beforeSuite() {
        await this.helpers.Playwright.restartBrowser();
    }
}

export = MyHelper;

Details

  • CodeceptJS version: 3.5.5
  • NodeJS Version: 18.15.0
  • Operating System: Ubuntu 22.04
  • Playwright 1.37.1
  • Configuration file:
export const config: CodeceptJS.MainConfig = {
    tests: "./*_test.ts",
    output: "./output",
    helpers: {
        Playwright: {
            browser: "chromium",
            url: "http://localhost",
            show: true,
        },
        MyHelper: {
            require: "./myhelper_helper.ts",
        },
    },
    name: "my",
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions