Testing an MEVN Application Chapter 9
test_settings: {
default: {
selenium_port: 4444,
selenium_host: 'localhost',
silent: true,
globals: {
devServerURL: 'http://localhost:' + (process.env.PORT ||
config.dev.port)
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
}
}
}
In the preceding code, in the setting inside the test_settings attribute, we can see the
different setups for different browsers. In this case, Chrome, Firefox, and the host and port
settings for the development environment to run on the browser.
Also, in the preceding code, we have specified two folders: specs and custom-
assertions.
The specs folder contains the main test code for the application
custom-assertion contains a script, which contains custom messages that get
displayed when assertion tests are run on the command line
Let's first set up our custom-assertions. Create a file called elementCount.js inside
custom-assertions and add the following contents to it:
// A custom Nightwatch assertion.
// The assertion name is the filename.
// Example usage: