Skip to content
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

Helper stopped working in CodeceptJS 3.x: Error: Could not load helper CmdHelper from module #4

Closed
mirao opened this issue Dec 3, 2020 · 2 comments

Comments

@mirao
Copy link
Contributor

mirao commented Dec 3, 2020

$ codeceptjs run --profile jobr --debug
(node:1889297) UnhandledPromiseRejectionWarning: Error: Could not load helper CmdHelper from module '/home/mirao/workspace/codeceptjs/node_modules/codeceptjs-cmdhelper':
Class extends value #<Object> is not a constructor or null
TypeError: Class extends value #<Object> is not a constructor or null
    at Object.<anonymous> (/home/mirao/workspace/codeceptjs/node_modules/codeceptjs-cmdhelper/index.js:11:25)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at createHelpers (/home/mirao/workspace/codeceptjs/node_modules/codeceptjs/lib/container.js:166:27)
    at Function.create (/home/mirao/workspace/codeceptjs/node_modules/codeceptjs/lib/container.js:43:25)
    at Codecept.init (/home/mirao/workspace/codeceptjs/node_modules/codeceptjs/lib/codecept.js:56:15)
    at createHelpers (/home/mirao/workspace/codeceptjs/node_modules/codeceptjs/lib/container.js:181:13)
    at Function.create (/home/mirao/workspace/codeceptjs/node_modules/codeceptjs/lib/container.js:43:25)
    at Codecept.init (/home/mirao/workspace/codeceptjs/node_modules/codeceptjs/lib/codecept.js:56:15)
    at Command.module.exports (/home/mirao/workspace/codeceptjs/node_modules/codeceptjs/lib/command/run.js:22:12)
    at Command.listener (/home/mirao/workspace/codeceptjs/node_modules/commander/index.js:315:8)
    at Command.emit (events.js:314:20)
    at Command.parseArgs (/home/mirao/workspace/codeceptjs/node_modules/commander/index.js:651:12)
    at Command.parse (/home/mirao/workspace/codeceptjs/node_modules/commander/index.js:474:21)
    at Object.<anonymous> (/home/mirao/workspace/codeceptjs/node_modules/codeceptjs/bin/codecept.js:189:9)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
(node:1889297) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1889297) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

codecept.conf.js:

        CmdHelper: {
            require: "../../node_modules/codeceptjs-cmdhelper"
        }

Workaround/solution: (it helped me even for my custom helpers which worked in 2.6.11 and stopped working in 3.0.x):

  • Remove the line const Helper = require('codeceptjs').helper; from node_modules/codeceptjs-cmdhelper/index.js
    image

Used SW:

  • Ubuntu 20.04
  • CodeceptJS 3.0.2
  • codeceptjs-cmdhelper@2.2.1
@thiagodp
Copy link
Owner

thiagodp commented Dec 8, 2020

Hello @mirao, thank you for checking it with CodeceptJS 3.x.

Currently I'm running out of time (for the next 3 weeks). So whether you can fix it, please feel free to send a PR.

@thiagodp
Copy link
Owner

thiagodp commented Dec 9, 2020

I did a quick check here with both versions 2.x and 3.x (on Windows OS) and didn't get the reported error. However, when I removed the line const Helper = require( 'codeceptjs' ).helper;, it also worked. So maybe it doesn't make a difference - let's remove it then.

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

2 participants