Skip to content

Commit e6706fd

Browse files
committed
Custom reporter feature: users can plug-in their reporters now
1 parent c77e4d8 commit e6706fd

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ You can choose to validate any or all of response status code, headers, JSON dat
3939
- Importing specs from multiple external suites
4040
- Intrasuite and Intersuite spec dependencies
4141
- Reusing test specification
42-
- Retry failed tests with wait time
42+
- Retry failed tests
4343
- Looping: Generate 'n' number of tests with a list
44+
- Built-in HTML, JSON reporters
4445
- Ability to generate reports in multiple formats for the same run
4546
- Logging HTTP request/response data for failed tests
4647
- Proper error reporting
4748
- Runs only tests matching with a given pattern/text
4849
- Skipping tests with specification
4950
- Disable or Enable redirections
51+
- Reports test duration
52+
- Allows user to plug-in custom reporters
5053

5154
[Find out all features](https://kiranz.github.io/just-api/features/)
5255

docs/docs/features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ And you can import specs from multiple suites by listing their relative paths.
661661
Note that these imported specs will only be available when you run them using `this.runSpec`.
662662

663663
Please find some examples on dependencies [here](https://github.com/kiranz/just-api/blob/master/test/cli/src/suites/suitedependencies/intersuitedeps.suite.yml)
664+
664665
## Skipping
665666
You can explicitly skip suites and tests with specification.
666667

lib/just-api.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class JustAPI {
5656
chosenReporters.push('specs')
5757
}
5858

59-
chosenReporters = Array.from(new Set(chosenReporters));
59+
chosenReporters = Array.from(new Set(chosenReporters));
6060

6161
for (let reporterInput of chosenReporters) {
6262
let Reporter;
@@ -72,8 +72,14 @@ export default class JustAPI {
7272
Reporter = require('./reporters/json.js');
7373
break;
7474
default:
75-
console.error(`Reporter: ${reporterInput} is unknown. Please provide a valid reporter`);
76-
process.exit(1);
75+
try {
76+
Reporter = require(reporterInput.trim());
77+
break;
78+
} catch (err) {
79+
console.error(`\nError occurred while loading the reporter: ${reporterInput.trim()}`);
80+
console.error(`\n ${err.stack}`);
81+
process.exit(1);
82+
}
7783
}
7884

7985
this.reporters.push(Reporter);

lib/launcher.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ export default class Launcher extends EventEmitter {
3636
this.reporters = [];
3737

3838
for (let Reporter of reporters) {
39-
let reporter = new Reporter(this, {
40-
parallel: this.parallel,
41-
reporterOptions: {...this.reporterOptions}
42-
});
39+
try {
40+
let reporter = new Reporter(this, {
41+
parallel: this.parallel,
42+
reporterOptions: {...this.reporterOptions}
43+
});
44+
45+
this.reporters.push(reporter);
46+
} catch (err) {
47+
console.error(`Error occurred while initializing reporter: ${Reporter.name} \n ${err.stack}`);
48+
process.exit(1);
49+
}
4350

44-
this.reporters.push(reporter);
4551
}
4652
}
4753

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "just-api",
3-
"version": "1.0.9",
3+
"version": "1.1.0",
44
"description": "Specification based API test framework for HTTP APIs (REST, GraphQL)",
55
"keywords": [
66
"API",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy