Skip to content

Shell: Command fails: "Cannot read properties of undefined (reading 'goto')" #4844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mirao opened this issue Feb 10, 2025 · 1 comment
Open

Comments

@mirao
Copy link
Contributor

mirao commented Feb 10, 2025

It's a regression in 3.7.0. It works well in 3.6.10.

Steps:

  • Initialize a project
npx create-codeceptjs .
npx codeceptjs init # Create a Playwright test, with "Show browser window = yes"
  • Run shell
mirao@jobr:~/workspace/my$ codeceptjs shell
Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module. Disable tryTo plugin to remove this warning.
Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module. Disable retryTo plugin to remove this warning.
Starting interactive shell for current suite...
Error processing test.before event:
TypeError: Cannot read properties of undefined (reading 'disableRetryFailedStep')
    at EventEmitter.<anonymous> (/home/mirao/workspace/my/node_modules/codeceptjs/lib/plugin/retryFailedStep.js:111:19)
    at EventEmitter.emit (node:events:536:35)
    at EventEmitter.emit (node:domain:489:12)
    at Object.emit (/home/mirao/workspace/my/node_modules/codeceptjs/lib/event.js:153:28)
    at module.exports (/home/mirao/workspace/my/node_modules/codeceptjs/lib/command/interactive.js:32:11)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Command.<anonymous> (/home/mirao/workspace/my/node_modules/codeceptjs/bin/codecept.js:38:7)
Error while loading home page: Cannot read properties of undefined (reading 'goto')}
 Interactive shell started
 Use JavaScript syntax to try steps in action
 - Press ENTER to run the next step
 - Press TAB twice to see all available commands
 - Type exit + Enter to exit the interactive shell
 - Prefix => to run js commands 
 I.

BTW the message TypeError: Cannot read properties of undefined (reading 'disableRetryFailedStep') is strange. Not sure if it affects the next behavior (but maybe it's a different issue). Could you look at it?

  • Enter amOnPage("https://codecept.io/")

Expected result:

  • The command is performed

Actual result:

  • It fails
 I.amOnPage("https://codecept.io/")
 ERROR  Cannot read properties of undefined (reading 'goto')
 I.TypeError: Chaining cycle detected for promise #<Promise>
    at processTicksAndRejections (node:internal/process/task_queues:105:5)

Also I would expect that a Chromium in windowed mode should be started in the shell mode, but it doesn't happen 🐛 .


codecept.conf.ts:

import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure';
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();

export const config: CodeceptJS.MainConfig = {
  tests: './*_test.ts',
  output: './output',
  helpers: {
    Playwright: {
      browser: 'chromium',
      url: 'http://localhost',
      show: true
    }
  },
  include: {
    I: './steps_file'
  },
  name: 'my'
}

Used SW:

  • CodeceptJS 3.7.0 or 3.7.2
  • Playwright 1.50.1
  • NodeJS 22
  • Ubuntu 24.04
@mirao
Copy link
Contributor Author

mirao commented Apr 15, 2025

I'm able to fix the issue TypeError: Cannot read properties of undefined (reading 'disableRetryFailedStep') by a help of CoPilot:

  event.dispatcher.on(event.test.before, test => {
    // Safely check for test and test.opts
    if (!test || !test.opts) {
      store.autoRetries = false;
      return; // Exit early if test or test.opts is undefined
    }
    ...
  }

but it's still failing on the TypeError: Chaining cycle detected for promise error if I call some method or if I just press ENTER

$ codeceptjs shell
Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module. Disable tryTo plugin to remove this warning.
Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module. Disable retryTo plugin to remove this warning.
Starting interactive shell for current suite...
 Interactive shell started
 Use JavaScript syntax to try steps in action
 - Press ENTER to run the next step
 - Press TAB twice to see all available commands
 - Type exit + Enter to exit the interactive shell
 - Prefix => to run js commands 
 I.see("Domain")
node:internal/process/task_queues:95
    runMicrotasks();
    ^

TypeError: Chaining cycle detected for promise #<Promise>
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.19.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant