codeceptjs / codeceptjs/CodeceptJS

[Enhancement] Add namespace definition for helper

Open
#2,638 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.2k
Forks
757
Avg merge
2d 9h
Merged PRs (30d)
16

Description

#### What are you trying to achieve?
Can we try to add namespace definition for helper. Because when we are writing helpers, there might be the same action for different scenarios. For example, I want to. add something to my favorite in desktop version or mobile version. But I don't want to write 2 different methods with different name like `addFavoriteInDesktop` and `addFavoriteInMobile`. I hope that I can have `addFavorite` methods in both `favorite_helper.js` in `desktop` folder and `favorite_helper.js` in `mobile` folder. But they have different namespace like
```
class FavoriteHelper extends Helper {
_namespace() {
return 'desktop';
}

addFavorite(something) {...}
}
```

Then I can use it in the test case like
```
Namespace('desktop');
Feature('Favorite');
Scenario('Add something to my favorite', (I) => {
I.addFavorite(something);
.....
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.