Skip to content

Commit eb12a2f

Browse files
committed
patch(subdirectories) allow subdirectories in page objects and share objects
1 parent 7c40725 commit eb12a2f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.vscode
22
node_modules
33
package-lock.json
4-
. idea/
4+
.idea/

README.MD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ The following variables are available within the ```Given()```, ```When()``` and
159159

160160
### Page objects
161161

162-
Page objects are accessible via a global ```page``` object and are automatically loaded from ```./page-objects``` _(or the path specified using the ```-p``` switch)_. Page objects are exposed via a camel-cased version of their filename, for example ```./page-objects/google-search.js``` becomes ```page.googleSearch```.
162+
Page objects are accessible via a global ```page``` object and are automatically loaded from ```./page-objects``` _(or the path specified using the ```-p``` switch)_. Page objects are exposed via a camel-cased version of their filename, for example ```./page-objects/google-search.js``` becomes ```page.googleSearch```. You can also use subdirectories, for example ```./page-objects/dir/google-search.js``` becomes ```page.dir.googleSearch```.
163163

164164
Page objects also have access to the same runtime variables available to step definitions.
165165

@@ -208,7 +208,8 @@ this.When(/^I search Google for "([^"]*)"$/, function (searchQuery) {
208208

209209
### Shared objects
210210

211-
Shared objects allow you to share anything from test data to helper methods throughout your project via a global ```shared``` object. Shared objects are automatically loaded from ```./shared-objects``` _(or the path specified using the ```-o``` switch)_ and made available via a camel-cased version of their filename, for example ```./shared-objects/test-data.js``` becomes ```shared.testData```.
211+
Shared objects allow you to share anything from test data to helper methods throughout your project via a global ```shared``` object. Shared objects are automatically loaded from ```./shared-objects``` _(or the path specified using the ```-o``` switch)_ and made available via a camel-cased version of their filename, for example ```./shared-objects/test-data.js``` becomes ```shared.testData```. You can also use subdirectories, for example ```./shared-objects/dir/test-data.js``` becomes ```shared.dir.testData```.
212+
212213

213214
Shared objects also have access to the same runtime variables available to step definitions.
214215

runtime/world.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function importSupportObjects() {
140140

141141
if (fs.existsSync(itemPath)) {
142142

143-
var dir = requireDir(itemPath, { camelcase: true });
143+
var dir = requireDir(itemPath, { camelcase: true, recurse: true });
144144

145145
merge(allDirs, dir);
146146
}
@@ -158,7 +158,7 @@ function importSupportObjects() {
158158
if (global.pageObjectPath && fs.existsSync(global.pageObjectPath)) {
159159

160160
// require all page objects using camel case as object names
161-
global.page = requireDir(global.pageObjectPath, { camelcase: true });
161+
global.page = requireDir(global.pageObjectPath, { camelcase: true, recurse: true });
162162
}
163163

164164
// add helpers

0 commit comments

Comments
 (0)