From 6d97d95391de4332f341809381477ba79edbc60b Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 9 Aug 2018 20:31:12 +0200 Subject: [PATCH] test: fix agent lambda tests when run with nyc (#505) This is a race condition. The tests would call t.end() before all their assertions had finished. This would not be an issue when running the tests normally, but when running via nyc it would fail. --- test/agent.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/agent.js b/test/agent.js index 0c584f88e5..077ce9dec1 100644 --- a/test/agent.js +++ b/test/agent.js @@ -607,6 +607,8 @@ test('#lambda()', function (t) { } t.test('success - basic callback', function (t) { + t.plan(2 + assertTransaction.asserts + assertContext.asserts) + var name = 'greet.hello' var input = { name: 'world' } var output = 'Hello, world!' @@ -621,7 +623,6 @@ test('#lambda()', function (t) { lambda.invoke(name, input, (err, result) => { t.error(err) t.equal(result, output) - t.end() }) }) .on('data-transaction', function (data) { @@ -631,6 +632,8 @@ test('#lambda()', function (t) { }) t.test('success - context.succeed', function (t) { + t.plan(2 + assertTransaction.asserts + assertContext.asserts) + var name = 'greet.hello' var input = { name: 'world' } var output = 'Hello, world!' @@ -645,7 +648,6 @@ test('#lambda()', function (t) { lambda.invoke(name, input, (err, result) => { t.error(err) t.equal(result, output) - t.end() }) }) .on('data-transaction', function (data) { @@ -655,6 +657,8 @@ test('#lambda()', function (t) { }) t.test('success - context.done', function (t) { + t.plan(2 + assertTransaction.asserts + assertContext.asserts) + var name = 'greet.hello' var input = { name: 'world' } var output = 'Hello, world!' @@ -669,7 +673,6 @@ test('#lambda()', function (t) { lambda.invoke(name, input, (err, result) => { t.error(err) t.equal(result, output) - t.end() }) }) .on('data-transaction', function (data) {