Skip to content

Commit 5310fde

Browse files
author
John Doherty
authored
Merge pull request #83 from bkarolyi/master
Allow subdirectories in page objects and shared objects
2 parents 5eb0f39 + eb12a2f commit 5310fde

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

README.MD

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

170170
### Page objects
171171

172-
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```.
172+
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```.
173173

174174
Page objects also have access to the same runtime variables available to step definitions.
175175

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

219219
### Shared objects
220220

221-
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```.
221+
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```.
222+
222223

223224
Shared objects also have access to the same runtime variables available to step definitions.
224225

runtime/world.js

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

144144
if (fs.existsSync(itemPath)) {
145145

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

148148
merge(allDirs, dir);
149149
}
@@ -161,7 +161,7 @@ function importSupportObjects() {
161161
if (global.pageObjectPath && fs.existsSync(global.pageObjectPath)) {
162162

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

167167
// add helpers

0 commit comments

Comments
 (0)