From 4d782c4720e3407eb77d7cf6ba76673a94ffae89 Mon Sep 17 00:00:00 2001 From: Hristijan Gjorgjievski Date: Wed, 6 Jun 2018 13:02:16 +1000 Subject: [PATCH] test: improve assert error messages Improve the assert error message so it includes actual value in the error message. PR-URL: https://github.com/nodejs/node/pull/21160 Reviewed-By: Weijia Wang Reviewed-By: Rich Trott Reviewed-By: Yuta Hiroto Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- test/parallel/test-stream-pipe-await-drain.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-stream-pipe-await-drain.js b/test/parallel/test-stream-pipe-await-drain.js index 5bdf48008479e7..53cf54940d34e1 100644 --- a/test/parallel/test-stream-pipe-await-drain.js +++ b/test/parallel/test-stream-pipe-await-drain.js @@ -23,8 +23,12 @@ writer1._write = common.mustCall(function(chunk, encoding, cb) { }, 1); writer1.once('chunk-received', function() { - assert.strictEqual(reader._readableState.awaitDrain, 0, - 'initial value is not 0'); + assert.strictEqual( + reader._readableState.awaitDrain, + 0, + 'awaitDrain initial value should be 0, actual is ' + + reader._readableState.awaitDrain + ); setImmediate(function() { // This one should *not* get through to writer1 because writer2 is not // "done" processing. @@ -35,8 +39,10 @@ writer1.once('chunk-received', function() { // A "slow" consumer: writer2._write = common.mustCall(function(chunk, encoding, cb) { assert.strictEqual( - reader._readableState.awaitDrain, 1, - 'awaitDrain isn\'t 1 after first push' + reader._readableState.awaitDrain, + 1, + 'awaitDrain should be 1 after first push, actual is ' + + reader._readableState.awaitDrain ); // Not calling cb here to "simulate" slow stream. // This should be called exactly once, since the first .write() call @@ -45,8 +51,10 @@ writer2._write = common.mustCall(function(chunk, encoding, cb) { writer3._write = common.mustCall(function(chunk, encoding, cb) { assert.strictEqual( - reader._readableState.awaitDrain, 2, - 'awaitDrain isn\'t 2 after second push' + reader._readableState.awaitDrain, + 2, + 'awaitDrain should be 2 after second push, actual is ' + + reader._readableState.awaitDrain ); // Not calling cb here to "simulate" slow stream. // This should be called exactly once, since the first .write() call