Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The same "I" instance being used in step runtime context cant be injected in custom helper #4559

attilagyoriid started this conversation in General
Discussion options

What are you trying to achieve?

to inject the same "I" instance as being used in step runtime context in custom helper

What do you get instead?

undefined or different "I" instance

Provide test source code if related
I tried it to achieve the I injection in many ways

1.
class MyHelper extends Helper {
constructor(prop) {
 super();
 const {I} = inject();  "I" is undefined
}
....
2.
class MyHelper extends Helper { 
myMethod = message => {
 const {I} = inject();  "I" it is not the same instance being used in the context of step execution
};
.....
3.
class MyHelper extends Helper
{
async _before() {
 const {I} = inject();  "I" it is not the same instance being used in the context of step execution
};

Details

  • CodeceptJS version: 3.6.7
  • NodeJS Version: v20.11.0
  • Operating System: macOS 15.0.01
  • puppeteer || webdriverio || testcafe version (if related)
  • Configuration file:
codecept.conf.js:
...
module.exports = {
 name: 'project',
 tests: '../src/tests/**/*_test.js',
 output: '../output',
 bootstrap: null,
 helpers: { 
 MyHelper: {
 require: '../src/lib/helpers/MyHelper.js',
 }
 },
......

The question:
Is there a way to get a hold of the same "I" instance being used during step exec and inject it into custom helper classes?

Thanks for your help and answer

Best Regards

Attila

You must be logged in to vote

Replies: 2 comments

Comment options

hey @attilagyoriid per my best knowledge, the I actor is not designed to be injected in custom helper.
https://codecept.io/helpers/#extending-codeceptjs-with-custom-helpers

perhaps @DavertMik could explain it better than myself.

You must be logged in to vote
0 replies
Comment options

Dear @kobenguyent thanks for the pretty fast reply

So If I understand correctly, custom helper classes are designed to implement those activities can not be achieved using I actor?

Other question being important:
In case of Page Object Model, can it be achieved to inject the same actor I instance being used during step context?

Thanks for your answer

Best Regards

Attila

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Converted from issue

This discussion was converted from issue #4520 on November 11, 2024 14:40.

AltStyle によって変換されたページ (->オリジナル) /