You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we get the error "the command .myCommand() is already defined." it's not always easy to understand in which exact files we got this duplication of commands.
So it would be great to display paths of both files that lead to this error.
Suggested solution
Add the file paths to the error message output, something like this:
File lib/api/_loaders/_command-loader.js - function validateMethod():
- const err = new TypeError(`Error while loading the API commands: the ${this.type} ${this.namespace || ''}.${this.commandName}() is already defined.`);+ const err = new TypeError(`Error while loading the API commands from the file ${this.fileName}: the ${this.type} ${this.namespace || ''}.${this.commandName}() is already defined by the file [the first file path].`);
But I can't find a way to find the first file path. When I find, I can make a PR with this feature.
Alternatives / Workarounds
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered:
@MurzNNmyCommand is usually the same as the file name of the command, is it not happening in your case? Or do you want the complete path of the file from the this.fileName?
Yeah, I want to see the complete path, because in some projects we have the same named commands in dependencies, and sometimes - symlinks to the same Nigtwatch directory from different places, which leads to this error, with no idea about what exact directories lead to this problem.
To address this issue we can modify the validateMethod function in Nightwatch's command loader to track and display the file paths where duplicate commands are defined. We can add a command registry and maintain a global registry to keep track of commands and their file paths during loading. This registry can map each command to the file path where it was first defined and then check if a command already exists in the registry. If a duplicate is found, we can throw an error that includes the file paths of both the first definition and the duplicate.
We can Include the file paths in the error message to clearly show where the duplication occurred.
I think this is the solution to this .... Is the implementation to this correct?
Description
When we get the error "the command .myCommand() is already defined." it's not always easy to understand in which exact files we got this duplication of commands.
So it would be great to display paths of both files that lead to this error.
Suggested solution
Add the file paths to the error message output, something like this:
File
lib/api/_loaders/_command-loader.js
- functionvalidateMethod()
:But I can't find a way to find the first file path. When I find, I can make a PR with this feature.
Alternatives / Workarounds
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: