Skip to content

Commit

Permalink
test: correct assertion argument order
Browse files Browse the repository at this point in the history
This conforms assertions to follow the argument order of
asserted then actual, and adds more explicit messages
to describe assertion failures.

PR-URL: #23618
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
JeffMarvin authored and MylesBorins committed Nov 29, 2018
1 parent 19e2e6d commit 5ce59a1
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions test/sequential/test-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ const assert = require('assert');
const { NodeInstance } = require('../common/inspector-helper.js');

function checkListResponse(response) {
assert.strictEqual(1, response.length);
const expectedLength = 1;
assert.strictEqual(
response.length,
expectedLength,
`Expected response length ${response.length} to be ${expectedLength}.`
);
assert.ok(response[0].devtoolsFrontendUrl);
assert.ok(
/ws:\/\/localhost:\d+\/[0-9A-Fa-f]{8}-/
Expand Down Expand Up @@ -41,7 +46,11 @@ function assertScopeValues({ result }, expected) {
for (const actual of result) {
const value = expected[actual.name];
if (value) {
assert.strictEqual(value, actual.value.value);
assert.strictEqual(
actual.value.value,
value,
`Expected scope values to be ${actual.value.value} instead of ${value}.`
);
unmatched.delete(actual.name);
}
}
Expand Down Expand Up @@ -117,15 +126,24 @@ async function testBreakpoint(session) {
'generatePreview': true
}
});

assert.strictEqual(1002, result.value);
const expectedEvaluation = 1002;
assert.strictEqual(
result.value,
expectedEvaluation,
`Expected evaluation to be ${expectedEvaluation}, got ${result.value}.`
);

result = (await session.send({
'method': 'Runtime.evaluate', 'params': {
'expression': '5 * 5'
}
})).result;
assert.strictEqual(25, result.value);
const expectedResult = 25;
assert.strictEqual(
result.value,
expectedResult,
`Expected Runtime.evaluate to be ${expectedResult}, got ${result.value}.`
);
}

async function testI18NCharacters(session) {
Expand Down Expand Up @@ -288,7 +306,13 @@ async function runTest() {
await testI18NCharacters(session);
await testCommandLineAPI(session);
await session.runToCompletion();
assert.strictEqual(55, (await child.expectShutdown()).exitCode);
const expectedExitCode = 55;
const { exitCode } = await child.expectShutdown();
assert.strictEqual(
exitCode,
expectedExitCode,
`Expected exit code to be ${expectedExitCode} but got ${expectedExitCode}.`
);
}

runTest();

0 comments on commit 5ce59a1

Please sign in to comment.