☕️ Classic, reliable, trusted test framework for Node.js and the browser
Add speed in -R json option (#4226) (#4434)
Kim Hyo Rin738a57574f3e
diff --git a/lib/reporters/json-stream.js b/lib/reporters/json-stream.jsindex 8caa8adf..87cf6072 100644--- a/lib/reporters/json-stream.js+++ b/lib/reporters/json-stream.js@@ -84,7 +84,8 @@ function clean(test) {fullTitle: test.fullTitle(),file: test.file,duration: test.duration,- currentRetry: test.currentRetry()+ currentRetry: test.currentRetry(),+ speed: test.speed};}diff --git a/lib/reporters/json.js b/lib/reporters/json.jsindex a46776ba..a314cd38 100644--- a/lib/reporters/json.js+++ b/lib/reporters/json.js@@ -90,6 +90,7 @@ function clean(test) {file: test.file,duration: test.duration,currentRetry: test.currentRetry(),+ speed: test.speed,err: cleanCycles(err)};}diff --git a/test/reporters/json-stream.spec.js b/test/reporters/json-stream.spec.jsindex 613b9279..58694e3f 100644--- a/test/reporters/json-stream.spec.js+++ b/test/reporters/json-stream.spec.js@@ -23,12 +23,14 @@ describe('JSON Stream reporter', function() {var expectedFile = 'someTest.spec.js';var expectedDuration = 1000;var currentRetry = 1;+ var expectedSpeed = 'fast';var expectedTest = makeExpectedTest(expectedTitle,expectedFullTitle,expectedFile,expectedDuration,- currentRetry+ currentRetry,+ expectedSpeed);var expectedErrorMessage = 'error message';var expectedErrorStack = 'error stack';@@ -78,6 +80,8 @@ describe('JSON Stream reporter', function() {expectedDuration +',"currentRetry":' +currentRetry ++ ',"speed":' ++ dQuote(expectedSpeed) +'}]\n');});@@ -111,6 +115,8 @@ describe('JSON Stream reporter', function() {expectedDuration +',"currentRetry":' +currentRetry ++ ',"speed":' ++ dQuote(expectedSpeed) +',"err":' +dQuote(expectedErrorMessage) +',"stack":' +@@ -147,6 +153,8 @@ describe('JSON Stream reporter', function() {expectedDuration +',"currentRetry":' +currentRetry ++ ',"speed":' ++ dQuote(expectedSpeed) +',"err":' +dQuote(expectedErrorMessage) +',"stack":null}]\n'diff --git a/test/reporters/json.spec.js b/test/reporters/json.spec.jsindex a92be622..3eca1e91 100644--- a/test/reporters/json.spec.js+++ b/test/reporters/json.spec.js@@ -84,6 +84,29 @@ describe('JSON reporter', function() {});});+ it('should have 1 test pass', function(done) {+ const test = new Test(testTitle, () => {});++ test.file = testFile;+ suite.addTest(test);++ runner.run(function(failureCount) {+ expect(runner, 'to satisfy', {+ testResults: {+ passes: [+ {+ title: testTitle,+ file: testFile,+ speed: /(slow|medium|fast)/+ }+ ]+ }+ });+ expect(failureCount, 'to be', 0);+ done();+ });+ });+it('should handle circular objects in errors', function(done) {var testTitle = 'json test 1';function CircleError() {