From 530b62fc0d25eb88cbd25acbb04adf7eb60eec60 Mon Sep 17 00:00:00 2001 From: Alec Ferguson Date: Fri, 6 Oct 2017 10:17:27 -0700 Subject: [PATCH] test: more informative test failure messages PR-URL: https://github.com/nodejs/node/pull/15977 Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen --- test/parallel/test-zlib-const.js | 33 ++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-zlib-const.js b/test/parallel/test-zlib-const.js index e4c673aff0fe09..d25a1ca6be033a 100644 --- a/test/parallel/test-zlib-const.js +++ b/test/parallel/test-zlib-const.js @@ -4,14 +4,35 @@ const assert = require('assert'); const zlib = require('zlib'); -assert.strictEqual(zlib.constants.Z_OK, 0, 'Z_OK should be 0'); +assert.strictEqual(zlib.constants.Z_OK, 0, + [ + 'Expected Z_OK to be 0;', + `got ${zlib.constants.Z_OK}` + ].join(' ')); zlib.constants.Z_OK = 1; -assert.strictEqual(zlib.constants.Z_OK, 0, 'Z_OK should be 0'); +assert.strictEqual(zlib.constants.Z_OK, 0, + [ + 'Z_OK should be immutable.', + `Expected to get 0, got ${zlib.constants.Z_OK}` + ].join(' ')); -assert.strictEqual(zlib.codes.Z_OK, 0, 'Z_OK should be 0'); +assert.strictEqual(zlib.codes.Z_OK, 0, + `Expected Z_OK to be 0; got ${zlib.codes.Z_OK}`); zlib.codes.Z_OK = 1; -assert.strictEqual(zlib.codes.Z_OK, 0, 'zlib.codes.Z_OK should be 0'); +assert.strictEqual(zlib.codes.Z_OK, 0, + [ + 'Z_OK should be immutable.', + `Expected to get 0, got ${zlib.codes.Z_OK}` + ].join(' ')); zlib.codes = { Z_OK: 1 }; -assert.strictEqual(zlib.codes.Z_OK, 0, 'zlib.codes.Z_OK should be 0'); +assert.strictEqual(zlib.codes.Z_OK, 0, + [ + 'Z_OK should be immutable.', + `Expected to get 0, got ${zlib.codes.Z_OK}` + ].join(' ')); -assert.ok(Object.isFrozen(zlib.codes), 'zlib.codes should be frozen'); +assert.ok(Object.isFrozen(zlib.codes), + [ + 'Expected zlib.codes to be frozen, but Object.isFrozen', + `returned ${Object.isFrozen(zlib.codes)}` + ].join(' '));