From 2942fa18673a5ad4716087f9c168f6392e1b0496 Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 16 Dec 2016 14:18:02 +0100 Subject: [PATCH] Tests: Make tracing tests more specific Check that the console and the default tracer are called with specific arguments in given order. Previously the order of calls wasn't checked. --- test/api/generated-parser-api.spec.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/api/generated-parser-api.spec.js b/test/api/generated-parser-api.spec.js index a22008a..b1827bb 100644 --- a/test/api/generated-parser-api.spec.js +++ b/test/api/generated-parser-api.spec.js @@ -75,8 +75,10 @@ describe("generated parser API", function() { parser.parse("b"); if (typeof console === "object") { - messages.forEach(message => { - expect(console.log.calledWithExactly(message)).to.equal(true); + expect(console.log.callCount).to.equal(messages.length); + messages.forEach((message, index) => { + let call = console.log.getCall(index); + expect(call.calledWithExactly(message)).to.equal(true); }); } } finally { @@ -147,8 +149,10 @@ describe("generated parser API", function() { parser.parse("b", { tracer: tracer }); - events.forEach(event => { - expect(tracer.trace.calledWithExactly(event)).to.equal(true); + expect(tracer.trace.callCount).to.equal(events.length); + events.forEach((event, index) => { + let call = tracer.trace.getCall(index); + expect(call.calledWithExactly(event)).to.equal(true); }); }); });