-
-
Notifications
You must be signed in to change notification settings - Fork 748
The same "I" instance being used in step runtime context cant be injected in custom helper #4559
-
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
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
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
Beta Was this translation helpful? Give feedback.