Vote count:
0
Using NodeJS v0.12.1, in the following, I am trying to read an external file into a config object, and execute some tests using the values provided by that object.
I thought that config
would be in scope for the before
function, but I am getting the error ReferenceError: config is not defined
for the first line in the before
function. Why can't config
be accessed within before
?
module.exports = {
config : require('../../testconfig.json'),
before : function (browser) {
pass = config.pass;
siteroot = config.local.address + config.local.subdir;
},
after : function (browser) {
//we'll come up with something later....
},
'Testing the Login page': function (browser) {
var greeting = 'Welcome, ' + user + '!';
browser
.url(siteroot)
.waitForElementVisible('body', 1000)
.setValue('input[id=UserNameEdit]', user)
.setValue('input[id=PasswordEdit]', pass)
.click('#LoginBtn')
.pause(1000)
.assert.containsText('#usergreeting', greeting)
}
};
asked 42 secs ago
NodeJS: understanding variable scope in modules
Aucun commentaire:
Enregistrer un commentaire