test: include expected result in error messages

PR-URL: https://github.com/nodejs/node/pull/16039
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Chowdhurian 2017-10-06 12:14:09 -07:00 committed by Ruben Bridgewater
parent abf8bae475
commit 6a9fd06173
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -115,6 +115,7 @@ testData.forEach((item) => {
assert.ifError(err); assert.ifError(err);
const actual = output.replace(spaces, ''); const actual = output.replace(spaces, '');
const scriptDomain = 'google-analytics.com';
// Assert that the input stripped of all whitespace contains the // Assert that the input stripped of all whitespace contains the
// expected list // expected list
assert(actual.includes(expected)); assert(actual.includes(expected));
@ -122,11 +123,12 @@ testData.forEach((item) => {
// Testing the insertion of Google Analytics script when // Testing the insertion of Google Analytics script when
// an analytics id is provided. Should not be present by default // an analytics id is provided. Should not be present by default
if (includeAnalytics) { if (includeAnalytics) {
assert(actual.includes('google-analytics.com'), assert(actual.includes(scriptDomain),
'Google Analytics script was not present'); `Google Analytics script was not present in "${actual}"`);
} else { } else {
assert.strictEqual(actual.includes('google-analytics.com'), false, assert.strictEqual(actual.includes(scriptDomain), false,
'Google Analytics script was present'); 'Google Analytics script was present in ' +
`"${actual}"`);
} }
})); }));
})); }));