From e307a35e90625b3e09f065533782a4217ecc5818 Mon Sep 17 00:00:00 2001 From: Jeff Marvin Date: Fri, 12 Oct 2018 11:47:03 -0700 Subject: [PATCH] test: correct assertion argument order This conforms assertions to follow the argument order of asserted then actual, and adds more explicit messages to describe assertion failures. --- test/sequential/test-inspector.js | 36 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/test/sequential/test-inspector.js b/test/sequential/test-inspector.js index 2a7a2ef4bf34ba..4a8804749afea8 100644 --- a/test/sequential/test-inspector.js +++ b/test/sequential/test-inspector.js @@ -8,7 +8,12 @@ const assert = require('assert'); const { NodeInstance } = require('../common/inspector-helper.js'); function checkListResponse(response) { - assert.strictEqual(1, response.length); + const expectedResponseLength = 1; + assert.strictEqual( + response.length, + expectedResponseLength, + `Expected list response length to be ${expectedResponseLength}.` + ); assert.ok(response[0].devtoolsFrontendUrl); assert.ok( /ws:\/\/localhost:\d+\/[0-9A-Fa-f]{8}-/ @@ -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); } } @@ -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) { @@ -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();