Skip to content

Commit

Permalink
Add support for mocha-json
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Feb 23, 2021
1 parent f285c4c commit 9b675bd
Show file tree
Hide file tree
Showing 21 changed files with 1,588 additions and 59 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ jobs:
# dotnet-trx
# flutter-json
# jest-junit
# mocha-json
reporter: ''
# Limits which test suites are listed:
Expand Down
40 changes: 40 additions & 0 deletions __tests__/__outputs__/mocha-json.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%205%20failed%2C%201%20skipped-critical)
## <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.
|Test suite|Passed|Failed|Skipped|Time|
|:---|---:|---:|---:|---:|
|[test/main.test.js](#r0s0)|1✔️|3❌||1ms|
|[test/second.test.js](#r0s1)||1❌|1✖️|NaNms|
|[test/test.js](#r0s2)||1❌||0ms|
### <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.

**Test 1**
|Result|Test|Time|
|:---:|:---|---:|
|✔️|Passing test|0ms|

**Test 1 Test 1.1**
|Result|Test|Time|
|:---:|:---|---:|
||Exception in target unit|0ms|
||Failing test|1ms|

**Test 2**
|Result|Test|Time|
|:---:|:---|---:|
||Exception in test|0ms|
### <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.

|Result|Test|Time|
|:---:|:---|---:|
|✖️|Skipped test|NaNms|
||Timeout test|10ms|
### <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|
137 changes: 137 additions & 0 deletions __tests__/__snapshots__/mocha-json.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`mocha-json tests report from ./reports/mocha-json test results matches snapshot 1`] = `
TestRunResult {
"path": "fixtures/mocha-json.json",
"suites": Array [
TestSuiteResult {
"groups": Array [
TestGroupResult {
"name": "Test 1",
"tests": Array [
TestCaseResult {
"error": undefined,
"name": "Passing test",
"result": "success",
"time": 0,
},
],
},
TestGroupResult {
"name": "Test 1 Test 1.1",
"tests": Array [
TestCaseResult {
"error": Object {
"details": "Error: Some error
at Object.throwError (lib\\\\main.js:2:9)
at Context.<anonymous> (test\\\\main.test.js:15:11)
at processImmediate (internal/timers.js:461:21)",
"line": 2,
"message": "Some error",
"path": "lib/main.js",
},
"name": "Exception in target unit",
"result": "failed",
"time": 0,
},
TestCaseResult {
"error": Object {
"details": "AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
false !== true
at Context.<anonymous> (test\\\\main.test.js:11:14)
at processImmediate (internal/timers.js:461:21)",
"line": 11,
"message": "Expected values to be strictly equal:
false !== true
",
"path": "test/main.test.js",
},
"name": "Failing test",
"result": "failed",
"time": 1,
},
],
},
TestGroupResult {
"name": "Test 2",
"tests": Array [
TestCaseResult {
"error": Object {
"details": "Error: Some error
at Context.<anonymous> (test\\\\main.test.js:22:11)
at processImmediate (internal/timers.js:461:21)",
"line": 22,
"message": "Some error",
"path": "test/main.test.js",
},
"name": "Exception in test",
"result": "failed",
"time": 0,
},
],
},
],
"name": "test/main.test.js",
"totalTime": undefined,
},
TestSuiteResult {
"groups": Array [
TestGroupResult {
"name": null,
"tests": Array [
TestCaseResult {
"error": undefined,
"name": "Skipped test",
"result": "skipped",
"time": undefined,
},
TestCaseResult {
"error": Object {
"details": "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)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)",
"line": undefined,
"message": "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)",
"path": undefined,
},
"name": "Timeout test",
"result": "failed",
"time": 10,
},
],
},
],
"name": "test/second.test.js",
"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,
}
`;
192 changes: 192 additions & 0 deletions __tests__/fixtures/mocha-json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
{
"stats": {
"suites": 5,
"tests": 7,
"passes": 1,
"pending": 1,
"failures": 5,
"start": "2021-02-23T14:20:41.144Z",
"end": "2021-02-23T14:20:41.158Z",
"duration": 14
},
"tests": [
{
"title": "Timeout test",
"fullTitle": "Timeout test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js",
"duration": 10,
"currentRetry": 0,
"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)",
"message": "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)",
"code": "ERR_MOCHA_TIMEOUT",
"timeout": 1,
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js"
}
},
{
"title": "Skipped test",
"fullTitle": "Skipped test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js",
"currentRetry": 0,
"err": {}
},
{
"title": "Passing test",
"fullTitle": "Test 1 Passing test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\main.test.js",
"duration": 0,
"currentRetry": 0,
"speed": "fast",
"err": {}
},
{
"title": "Failing test",
"fullTitle": "Test 1 Test 1.1 Failing test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\main.test.js",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\n\nfalse !== true\n\n at Context.<anonymous> (test\\main.test.js:11:14)\n at processImmediate (internal/timers.js:461:21)",
"message": "Expected values to be strictly equal:\n\nfalse !== true\n",
"generatedMessage": true,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": "false",
"expected": "true",
"operator": "strictEqual"
}
},
{
"title": "Exception in target unit",
"fullTitle": "Test 1 Test 1.1 Exception in target unit",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\main.test.js",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "Error: Some error\n at Object.throwError (lib\\main.js:2:9)\n at Context.<anonymous> (test\\main.test.js:15:11)\n at processImmediate (internal/timers.js:461:21)",
"message": "Some error"
}
},
{
"title": "Exception in test",
"fullTitle": "Test 2 Exception in test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\main.test.js",
"duration": 0,
"currentRetry": 0,
"err": {
"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"
}
},
{
"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": [
{
"title": "Skipped test",
"fullTitle": "Skipped test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js",
"currentRetry": 0,
"err": {}
}
],
"failures": [
{
"title": "Timeout test",
"fullTitle": "Timeout test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js",
"duration": 10,
"currentRetry": 0,
"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)",
"message": "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)",
"code": "ERR_MOCHA_TIMEOUT",
"timeout": 1,
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\second.test.js"
}
},
{
"title": "Failing test",
"fullTitle": "Test 1 Test 1.1 Failing test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\main.test.js",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\n\nfalse !== true\n\n at Context.<anonymous> (test\\main.test.js:11:14)\n at processImmediate (internal/timers.js:461:21)",
"message": "Expected values to be strictly equal:\n\nfalse !== true\n",
"generatedMessage": true,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": "false",
"expected": "true",
"operator": "strictEqual"
}
},
{
"title": "Exception in target unit",
"fullTitle": "Test 1 Test 1.1 Exception in target unit",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\main.test.js",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "Error: Some error\n at Object.throwError (lib\\main.js:2:9)\n at Context.<anonymous> (test\\main.test.js:15:11)\n at processImmediate (internal/timers.js:461:21)",
"message": "Some error"
}
},
{
"title": "Exception in test",
"fullTitle": "Test 2 Exception in test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\main.test.js",
"duration": 0,
"currentRetry": 0,
"err": {
"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"
}
},
{
"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": [
{
"title": "Passing test",
"fullTitle": "Test 1 Passing test",
"file": "C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\mocha\\test\\main.test.js",
"duration": 0,
"currentRetry": 0,
"speed": "fast",
"err": {}
}
]
}
Loading

0 comments on commit 9b675bd

Please sign in to comment.