Nightwatch accepts a second globals.json
configuration file which injects data into the test runner itself, very similar to how Meteor.settings
makes data from the command line available throughout the app.
globals.json
{
"default" : {
"url" : "http://localhost:3000",
"user": {
"name": "Jane Doe",
"username" : "janedoe",
"password" : "janedoe123",
"email" : "[email protected]",
"userId": null
}
},
"circle" : {
"url" : "http://localhost:3000",
"user": {
"name": "Jane Doe",
"username" : "janedoe",
"password" : "janedoe123",
"email" : "[email protected]"
"userId": null
}
},
"galaxy" : {
"url" : "http://myapp.meteorapp.com",
"user": {
"name": "Jane Doe",
"username" : "janedoe",
"password" : "janedoe123",
"email" : "[email protected]"
"userId": null
}
}
}
You can then write your tests that aren't hardcoded with specific users, passwords, search inputs, etc.
module.exports = {
"Login App" : function (client) {
client
.url(client.globals.url)
.login(client.globals.user.email, client.globals.user.password)
.end();
}
};