Skip to content

Commit

Permalink
Add speed in -R json option (#4226) (#4434)
Browse files Browse the repository at this point in the history
* issue 4226 : add print speed in json

* add print speed json-stream and json-stream.spec.js

* add print speed json-stream and json-stream.spec.js

* add pass test case in json.spec.js

* Update test/reporters/json.spec.js

Co-authored-by: Christopher Hiller <boneskull@boneskull.com>

* Update test/reporters/json.spec.js

Co-authored-by: Christopher Hiller <boneskull@boneskull.com>

* Update test/reporters/json.spec.js

Co-authored-by: Christopher Hiller <boneskull@boneskull.com>

* remove the testSpeed

Co-authored-by: Christopher Hiller <boneskull@boneskull.com>
  • Loading branch information
wwhurin and boneskull committed Sep 13, 2020
1 parent 5bdc208 commit 738a575
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/reporters/json-stream.js
Expand Up @@ -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
};
}

Expand Down
1 change: 1 addition & 0 deletions lib/reporters/json.js
Expand Up @@ -90,6 +90,7 @@ function clean(test) {
file: test.file,
duration: test.duration,
currentRetry: test.currentRetry(),
speed: test.speed,
err: cleanCycles(err)
};
}
Expand Down
10 changes: 9 additions & 1 deletion test/reporters/json-stream.spec.js
Expand Up @@ -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';
Expand Down Expand Up @@ -78,6 +80,8 @@ describe('JSON Stream reporter', function() {
expectedDuration +
',"currentRetry":' +
currentRetry +
',"speed":' +
dQuote(expectedSpeed) +
'}]\n'
);
});
Expand Down Expand Up @@ -111,6 +115,8 @@ describe('JSON Stream reporter', function() {
expectedDuration +
',"currentRetry":' +
currentRetry +
',"speed":' +
dQuote(expectedSpeed) +
',"err":' +
dQuote(expectedErrorMessage) +
',"stack":' +
Expand Down Expand Up @@ -147,6 +153,8 @@ describe('JSON Stream reporter', function() {
expectedDuration +
',"currentRetry":' +
currentRetry +
',"speed":' +
dQuote(expectedSpeed) +
',"err":' +
dQuote(expectedErrorMessage) +
',"stack":null}]\n'
Expand Down
23 changes: 23 additions & 0 deletions test/reporters/json.spec.js
Expand Up @@ -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() {
Expand Down

0 comments on commit 738a575

Please sign in to comment.