Skip to content

Commit 738a575

Browse files
wwhurinboneskull
andauthored
Add speed in -R json option (#4226) (#4434)
* 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>
1 parent 5bdc208 commit 738a575

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

lib/reporters/json-stream.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ function clean(test) {
8484
fullTitle: test.fullTitle(),
8585
file: test.file,
8686
duration: test.duration,
87-
currentRetry: test.currentRetry()
87+
currentRetry: test.currentRetry(),
88+
speed: test.speed
8889
};
8990
}
9091

lib/reporters/json.js

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function clean(test) {
9090
file: test.file,
9191
duration: test.duration,
9292
currentRetry: test.currentRetry(),
93+
speed: test.speed,
9394
err: cleanCycles(err)
9495
};
9596
}

test/reporters/json-stream.spec.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ describe('JSON Stream reporter', function() {
2323
var expectedFile = 'someTest.spec.js';
2424
var expectedDuration = 1000;
2525
var currentRetry = 1;
26+
var expectedSpeed = 'fast';
2627
var expectedTest = makeExpectedTest(
2728
expectedTitle,
2829
expectedFullTitle,
2930
expectedFile,
3031
expectedDuration,
31-
currentRetry
32+
currentRetry,
33+
expectedSpeed
3234
);
3335
var expectedErrorMessage = 'error message';
3436
var expectedErrorStack = 'error stack';
@@ -78,6 +80,8 @@ describe('JSON Stream reporter', function() {
7880
expectedDuration +
7981
',"currentRetry":' +
8082
currentRetry +
83+
',"speed":' +
84+
dQuote(expectedSpeed) +
8185
'}]\n'
8286
);
8387
});
@@ -111,6 +115,8 @@ describe('JSON Stream reporter', function() {
111115
expectedDuration +
112116
',"currentRetry":' +
113117
currentRetry +
118+
',"speed":' +
119+
dQuote(expectedSpeed) +
114120
',"err":' +
115121
dQuote(expectedErrorMessage) +
116122
',"stack":' +
@@ -147,6 +153,8 @@ describe('JSON Stream reporter', function() {
147153
expectedDuration +
148154
',"currentRetry":' +
149155
currentRetry +
156+
',"speed":' +
157+
dQuote(expectedSpeed) +
150158
',"err":' +
151159
dQuote(expectedErrorMessage) +
152160
',"stack":null}]\n'

test/reporters/json.spec.js

+23
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,29 @@ describe('JSON reporter', function() {
8484
});
8585
});
8686

87+
it('should have 1 test pass', function(done) {
88+
const test = new Test(testTitle, () => {});
89+
90+
test.file = testFile;
91+
suite.addTest(test);
92+
93+
runner.run(function(failureCount) {
94+
expect(runner, 'to satisfy', {
95+
testResults: {
96+
passes: [
97+
{
98+
title: testTitle,
99+
file: testFile,
100+
speed: /(slow|medium|fast)/
101+
}
102+
]
103+
}
104+
});
105+
expect(failureCount, 'to be', 0);
106+
done();
107+
});
108+
});
109+
87110
it('should handle circular objects in errors', function(done) {
88111
var testTitle = 'json test 1';
89112
function CircleError() {

0 commit comments

Comments
 (0)