-
-
Notifications
You must be signed in to change notification settings - Fork 725
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
Intellisense and custom steps file using Javascript #4153
Comments
@sethvanwykJET have you try to setup your function inside page-object or inside helper (i prefer async function inside helper) I don't use much actor option. |
I'm kinda love to go with this approach, combining all related steps into a file then importing it in steps file. |
@alaz-aura is your repo in typescript or JS? From what I understand the issue is not present in Typescript repo's. @Horsty80 The steps file is capable of using codeceptJS methods, while helpers are unable to due to it creating a circular dependency. @kobenguyent not really familiar with that approach, but the code I have currently aligns with the codeceptJS documentation, so if it needs adjustment then the documentation needs to be updated with the expected layout |
You can use codeceptjs method inside an help class MyCustomHelper extends Helper {
async customMethod(params) {
const { I } = inject();
I.seeElement(myLocator);
... Otherwise if check my method inside step file my /// <reference types='codeceptjs' />
type steps_file = typeof import('./custom-steps');
declare namespace CodeceptJS {
interface I extends ReturnType<steps_file> {} Have you try this ? My step file is very simple with a login function export = () =>
actor({
customLogin: () => {},
}); And in any of my test i have the autocomplete on I with Have you link for you repo ? You speak about InteliJ & Vscode, don't forget that InteliJ is "smarter" than vscode and can index all your code to propose enhanced I use Vscode, and my codecept project is with typescript. |
I'm unable to link the repo as it's private But I'll have a look to see if your suggestions work throughout the week, just got back from leave and have a backlog of tasks to get through first 😅 |
Hey @sethvanwykJET - yup it's in a TS repo. Hmmm sounds like you need further investigation. Good luck! 🤞 |
This doesn't really work in a JS repo, as this is TS. From what I understand this issue is JS specific I'll see if I can migrate the contents to a helper instead to see how that goes. |
When I try to do this, test execution stalls as soon as I try to use any It doesn't crash the test, it just doesn't do anything when it reaches that step within a helper file. Worth noting, it doesn't return an error saying that it's not a function. If I try to invoke a function that does not exist in |
Have you follow the doc about custom helper ? https://codecept.io/helpers/#development You need two steps for this to work:
const Helper = require('@codeceptjs/helper');
class MyHelper extends Helper {
helpers: {
WebDriver: { },
MyHelper: {
require: './path/to/module'
}
} |
This work was already present. We've got a few helpers already configured. The intellisense works with the code being in the helper, but it remains non-functional when using any everything outside of Also our codebase is |
This issue is stale because it has been open for 90 days with no activity. |
Discussed in #4091
Originally posted by sethvanwykJET December 28, 2023
Please note. This issue is Javascript specific. It doesn't seem to occur in typescript repos
So I've run into a bit of a nuisance.
I noticed that any code we add into the custom steps file isn't detected by VS Code
https://codecept.io/pageobjects/#actor
This is leading to a lot of confusion and sometimes team members removing required code due to their IDE telling them it's redundant.
Our codebase uses Javascript
In this example there will are 2 problems.
One, You can't deep-link back to myAsyncFunction by cmd+clicking it (MacOS)
And two, the IDE will berate you for using await on a non-promise
Refactor this redundant 'await' on a non-promise.
These are example from within the steps file itself, but it extends past that.
When using these functions inside of tests they also don't support intellisense and complain about using await on non-promises.
Additional note, the native CodeceptJS functions do support intellisense, this only happens for code that's new in the steps file.
The problem does not seem to exist in other IDE's. Colleagues that use Jetbrains seem to be able to use this without issues.
The text was updated successfully, but these errors were encountered: