Skip to content

Commit

Permalink
Improve output messages in link tests
Browse files Browse the repository at this point in the history
  • Loading branch information
openjck committed Jun 28, 2018
1 parent ac4970c commit 9ebbb3d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/tests/nightwatch/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ const request = require('request');


function notNotFound(browser, url) {
const successMessage = `Loaded successfully: ${url}`;

// URLs that the React app manages. These don't return a 404 but instead
// display a "Not Found" message.
if (url.startsWith('http://localhost:3000')) {
browser.url(url);
browser.expect.element('#not-found').to.not.be.present;
browser.waitForElementNotPresent('#not-found', successMessage);
browser.back();
}

// External URLs. These should return 404 if they're invalid.
else {
request(url, (error, response) => {
if (response === undefined) {
browser.assert.fail('response is undefined');
browser.assert.fail(`response is undefined for ${url}`);
} else {
browser.assert.equal(response.statusCode, 200);
browser.assert.equal(response.statusCode, 200, successMessage);
}
});
}
Expand Down

0 comments on commit 9ebbb3d

Please sign in to comment.