mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
Fix mocha report fixture + test duration handling
This commit is contained in:
parent
9b675bd55f
commit
8dba8714d0
6 changed files with 20 additions and 87 deletions
|
|
@ -1,11 +1,10 @@
|
||||||

|

|
||||||
## <a id="user-content-r0" href="#r0">fixtures/mocha-json.json</a> ❌
|
## <a id="user-content-r0" href="#r0">fixtures/mocha-json.json</a> ❌
|
||||||
**7** tests were completed in **14ms** with **1** passed, **5** failed and **1** skipped.
|
**6** tests were completed in **12ms** with **1** passed, **4** failed and **1** skipped.
|
||||||
|Test suite|Passed|Failed|Skipped|Time|
|
|Test suite|Passed|Failed|Skipped|Time|
|
||||||
|:---|---:|---:|---:|---:|
|
|:---|---:|---:|---:|---:|
|
||||||
|[test/main.test.js](#r0s0)|1✔️|3❌||1ms|
|
|[test/main.test.js](#r0s0)|1✔️|3❌||1ms|
|
||||||
|[test/second.test.js](#r0s1)||1❌|1✖️|NaNms|
|
|[test/second.test.js](#r0s1)||1❌|1✖️|8ms|
|
||||||
|[test/test.js](#r0s2)||1❌||0ms|
|
|
||||||
### <a id="user-content-r0s0" href="#r0s0">test/main.test.js</a> ❌
|
### <a id="user-content-r0s0" href="#r0s0">test/main.test.js</a> ❌
|
||||||
**4** tests were completed in **1ms** with **1** passed, **3** failed and **0** skipped.
|
**4** tests were completed in **1ms** with **1** passed, **3** failed and **0** skipped.
|
||||||
|
|
||||||
|
|
@ -25,16 +24,9 @@
|
||||||
|:---:|:---|---:|
|
|:---:|:---|---:|
|
||||||
|❌|Exception in test|0ms|
|
|❌|Exception in test|0ms|
|
||||||
### <a id="user-content-r0s1" href="#r0s1">test/second.test.js</a> ❌
|
### <a id="user-content-r0s1" href="#r0s1">test/second.test.js</a> ❌
|
||||||
**2** tests were completed in **NaNms** with **0** passed, **1** failed and **1** skipped.
|
**2** tests were completed in **8ms** with **0** passed, **1** failed and **1** skipped.
|
||||||
|
|
||||||
|Result|Test|Time|
|
|Result|Test|Time|
|
||||||
|:---:|:---|---:|
|
|:---:|:---|---:|
|
||||||
|✖️|Skipped test|NaNms|
|
|✖️|Skipped test|0ms|
|
||||||
|❌|Timeout test|10ms|
|
|❌|Timeout test|8ms|
|
||||||
### <a id="user-content-r0s2" href="#r0s2">test/test.js</a> ❌
|
|
||||||
**1** tests were completed in **0ms** with **0** passed, **1** failed and **0** skipped.
|
|
||||||
|
|
||||||
**Array #indexOf()**
|
|
||||||
|Result|Test|Time|
|
|
||||||
|:---:|:---|---:|
|
|
||||||
|❌|should return -1 when the value is not present|0ms|
|
|
||||||
|
|
@ -86,7 +86,7 @@ false !== true
|
||||||
"error": undefined,
|
"error": undefined,
|
||||||
"name": "Skipped test",
|
"name": "Skipped test",
|
||||||
"result": "skipped",
|
"result": "skipped",
|
||||||
"time": undefined,
|
"time": 0,
|
||||||
},
|
},
|
||||||
TestCaseResult {
|
TestCaseResult {
|
||||||
"error": Object {
|
"error": Object {
|
||||||
|
|
@ -99,7 +99,7 @@ false !== true
|
||||||
},
|
},
|
||||||
"name": "Timeout test",
|
"name": "Timeout test",
|
||||||
"result": "failed",
|
"result": "failed",
|
||||||
"time": 10,
|
"time": 8,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -107,31 +107,7 @@ false !== true
|
||||||
"name": "test/second.test.js",
|
"name": "test/second.test.js",
|
||||||
"totalTime": undefined,
|
"totalTime": undefined,
|
||||||
},
|
},
|
||||||
TestSuiteResult {
|
|
||||||
"groups": Array [
|
|
||||||
TestGroupResult {
|
|
||||||
"name": "Array #indexOf()",
|
|
||||||
"tests": Array [
|
|
||||||
TestCaseResult {
|
|
||||||
"error": Object {
|
|
||||||
"details": "AssertionError [ERR_ASSERTION]: 2 == -1
|
|
||||||
at Context.<anonymous> (test\\\\test.js:5:14)
|
|
||||||
at processImmediate (internal/timers.js:461:21)",
|
|
||||||
"line": undefined,
|
|
||||||
"message": "2 == -1",
|
|
||||||
"path": undefined,
|
|
||||||
},
|
|
||||||
"name": "should return -1 when the value is not present",
|
|
||||||
"result": "failed",
|
|
||||||
"time": 0,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"name": "test/test.js",
|
|
||||||
"totalTime": undefined,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
"totalTime": 14,
|
"totalTime": 12,
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
{
|
{
|
||||||
"stats": {
|
"stats": {
|
||||||
"suites": 5,
|
"suites": 3,
|
||||||
"tests": 7,
|
"tests": 6,
|
||||||
"passes": 1,
|
"passes": 1,
|
||||||
"pending": 1,
|
"pending": 1,
|
||||||
"failures": 5,
|
"failures": 4,
|
||||||
"start": "2021-02-23T14:20:41.144Z",
|
"start": "2021-02-24T20:26:09.297Z",
|
||||||
"end": "2021-02-23T14:20:41.158Z",
|
"end": "2021-02-24T20:26:09.309Z",
|
||||||
"duration": 14
|
"duration": 12
|
||||||
},
|
},
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{
|
||||||
"title": "Timeout test",
|
"title": "Timeout test",
|
||||||
"fullTitle": "Timeout test",
|
"fullTitle": "Timeout test",
|
||||||
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js",
|
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js",
|
||||||
"duration": 10,
|
"duration": 8,
|
||||||
"currentRetry": 0,
|
"currentRetry": 0,
|
||||||
"err": {
|
"err": {
|
||||||
"stack": "Error: Timeout of 1ms exceeded. For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves. (C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js)\n at listOnTimeout (internal/timers.js:554:17)\n at processTimers (internal/timers.js:497:7)",
|
"stack": "Error: Timeout of 1ms exceeded. For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves. (C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js)\n at listOnTimeout (internal/timers.js:554:17)\n at processTimers (internal/timers.js:497:7)",
|
||||||
|
|
@ -78,23 +78,6 @@
|
||||||
"stack": "Error: Some error\n at Context.<anonymous> (test\\main.test.js:22:11)\n at processImmediate (internal/timers.js:461:21)",
|
"stack": "Error: Some error\n at Context.<anonymous> (test\\main.test.js:22:11)\n at processImmediate (internal/timers.js:461:21)",
|
||||||
"message": "Some error"
|
"message": "Some error"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "should return -1 when the value is not present",
|
|
||||||
"fullTitle": "Array #indexOf() should return -1 when the value is not present",
|
|
||||||
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\test.js",
|
|
||||||
"duration": 0,
|
|
||||||
"currentRetry": 0,
|
|
||||||
"err": {
|
|
||||||
"stack": "AssertionError [ERR_ASSERTION]: 2 == -1\n at Context.<anonymous> (test\\test.js:5:14)\n at processImmediate (internal/timers.js:461:21)",
|
|
||||||
"message": "2 == -1",
|
|
||||||
"generatedMessage": true,
|
|
||||||
"name": "AssertionError",
|
|
||||||
"code": "ERR_ASSERTION",
|
|
||||||
"actual": "2",
|
|
||||||
"expected": "-1",
|
|
||||||
"operator": "=="
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"pending": [
|
"pending": [
|
||||||
|
|
@ -111,7 +94,7 @@
|
||||||
"title": "Timeout test",
|
"title": "Timeout test",
|
||||||
"fullTitle": "Timeout test",
|
"fullTitle": "Timeout test",
|
||||||
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js",
|
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js",
|
||||||
"duration": 10,
|
"duration": 8,
|
||||||
"currentRetry": 0,
|
"currentRetry": 0,
|
||||||
"err": {
|
"err": {
|
||||||
"stack": "Error: Timeout of 1ms exceeded. For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves. (C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js)\n at listOnTimeout (internal/timers.js:554:17)\n at processTimers (internal/timers.js:497:7)",
|
"stack": "Error: Timeout of 1ms exceeded. For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves. (C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js)\n at listOnTimeout (internal/timers.js:554:17)\n at processTimers (internal/timers.js:497:7)",
|
||||||
|
|
@ -159,23 +142,6 @@
|
||||||
"stack": "Error: Some error\n at Context.<anonymous> (test\\main.test.js:22:11)\n at processImmediate (internal/timers.js:461:21)",
|
"stack": "Error: Some error\n at Context.<anonymous> (test\\main.test.js:22:11)\n at processImmediate (internal/timers.js:461:21)",
|
||||||
"message": "Some error"
|
"message": "Some error"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "should return -1 when the value is not present",
|
|
||||||
"fullTitle": "Array #indexOf() should return -1 when the value is not present",
|
|
||||||
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\test.js",
|
|
||||||
"duration": 0,
|
|
||||||
"currentRetry": 0,
|
|
||||||
"err": {
|
|
||||||
"stack": "AssertionError [ERR_ASSERTION]: 2 == -1\n at Context.<anonymous> (test\\test.js:5:14)\n at processImmediate (internal/timers.js:461:21)",
|
|
||||||
"message": "2 == -1",
|
|
||||||
"generatedMessage": true,
|
|
||||||
"name": "AssertionError",
|
|
||||||
"code": "ERR_ASSERTION",
|
|
||||||
"actual": "2",
|
|
||||||
"expected": "-1",
|
|
||||||
"operator": "=="
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"passes": [
|
"passes": [
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Generates test fixtures for test-reporter action",
|
"description": "Generates test fixtures for test-reporter action",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test-json": "mocha --reporter json > ../../__tests__/fixtures/mocha-json.json",
|
"test": "mocha --reporter json > ../../__tests__/fixtures/mocha-json.json"
|
||||||
"test": "mocha"
|
|
||||||
},
|
},
|
||||||
"author": "Michal Dorner <dorner.michal@gmail.com>",
|
"author": "Michal Dorner <dorner.michal@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ export class MochaJsonParser implements TestParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
const error = this.getTestCaseError(test)
|
const error = this.getTestCaseError(test)
|
||||||
const testCase = new TestCaseResult(test.title, result, test.duration, error)
|
const testCase = new TestCaseResult(test.title, result, test.duration ?? 0, error)
|
||||||
group.tests.push(testCase)
|
group.tests.push(testCase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export interface MochaJsonTest {
|
||||||
title: string
|
title: string
|
||||||
fullTitle: string
|
fullTitle: string
|
||||||
file: string
|
file: string
|
||||||
duration: number
|
duration?: number
|
||||||
err: MochaJsonTestError
|
err: MochaJsonTestError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue