CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

`.config({ manualStart: true })` logs error, and unable to start browsers manually (Playwright)

Open ghost opened this issue 3 years ago • 4 comments

Operation

  • Updating our project to codeceptjs 3.3.3 (from 3.0.7)
  • Using Playwright
  • Running any Feature/Scenario with .config({ manualStart: true })

Outcome

An error is logged to the console:

TypeError: Cannot read properties of undefined (reading 'newContext')

And we're unable to start browsers manually with:

await this.helpers.Playwright._startBrowser();

What are you trying to achieve?

Using the config({ manualStart: true }) option without error, and (maybe separately) start browsers manually with this.helpers.Playwright._startBrowser()

What do you get instead?

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

➜ npx codeceptjs run --verbose
context
CodeceptJS v3.3.3 #StandWithUkraine
Using test root "/Users/djyarberjr/Desktop/base_codeceptjs"
Helpers: Playwright, REST, AssertWrapper
Plugins: screenshotOnFail

Feature name --
    [1]  Starting recording promises
context
 › [Suite Config] Playwright {"manualStart":true}
    Timeouts: 
  Scenario name
    [1] Error | TypeError: Cannot read properties of undefined (reading 'newContext')
TypeError: Cannot read properties of undefined (reading 'newContext')
  ✔ OK in 5ms

context
 › [Suite Config] Reverted for Playwright

  OK  | 1 passed   // 20ms

Provide test source code if related

tests/test.ts

Feature("Feature name").config({ manualStart: true });
Scenario("Scenario name", ({ I }) => {
  I.assert(1, 1);
});

Details

  • CodeceptJS version: 3.3.3
  • NodeJS Version: v16.14.2
  • Operating System: macOS, Big Sur, Version 11.6.5 (20G527)
  • Playwright 1.22.2
  • Configuration file:
require("ts-node/register");

exports.config = {
  tests: "./tests/**/*.ts",
  output: "./output",
  helpers: {
    Playwright: {
      url: "https://example.com",
      show: true,
      browser: "chromium",
    },
    REST: {},
    AssertWrapper: {
      require: "codeceptjs-assert",
    },
  },
  include: {
    I: "./steps_file.js",
  },
  bootstrap: null,
  mocha: {},
  name: "base_codeceptjs",
};

ghost avatar Jun 08 '22 16:06 ghost

I'm starting browser this way: https://github.com/codeceptjs/CodeceptJS/issues/3248#issuecomment-1036619609 . Maybe it helps you.

mirao avatar Aug 20 '22 10:08 mirao

Thanks! That does allow me to work around the issue! Can I ask how you are persisting the change (eg, forking the repo)?

Also totally fine if this was just an example to prove it works - which is a success! 😄

ghost avatar Aug 31 '22 16:08 ghost

Can I ask how you are persisting the change (eg, forking the repo) @ImperfectDJ

  • Make a change in a CodeceptJS helper in your project (I suppose you cloned it from Git)
  • Run npx patch-package codeceptjs in root of your project - it creates a patch file with your changes (it's a diff between orig file and changed file)
  • Then anytime you run npm ci in your project, CodeceptJS is installed and the patch is applied

mirao avatar Aug 31 '22 16:08 mirao

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Dec 13 '23 02:12 github-actions[bot]