Skip to content

Commit

Permalink
feat: Argument outFile takes an extension
Browse files Browse the repository at this point in the history
  • Loading branch information
pawfa committed Apr 14, 2021
1 parent e6334c6 commit b089776
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ $ judge-d verify --help
```

```
Verify contracts
It verifies contracts and generates HTML report if outFile is provided
Options:
--url Url to judge-d instance [string] [required]
--serviceName Service name [string] [required]
--serviceVersion Service version [string] [required]
--environment Environment name [string] [required]
--outFile Path with HTML report filename [string]
--outFile Path with HTML report filename, ex. report.html [string]
```
2 changes: 1 addition & 1 deletion src/utils/define-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function defineArgs(
},
outFile: {
type: 'string',
describe: 'Path with HTML report filename',
describe: 'Path with HTML report filename, ex. report.html',
},
});
})
Expand Down
2 changes: 1 addition & 1 deletion src/utils/write-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export function writeReport(outFile: string, htmlReport: string) {
if (!fs.existsSync(pathToReportDir)) {
fs.mkdirSync(pathToReportDir, { recursive: true });
}
fs.writeFileSync(`${outFile}.html`, htmlReport);
fs.writeFileSync(outFile, htmlReport);
}
7 changes: 6 additions & 1 deletion test/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('run', () => {
mocked(axios.get).mockResolvedValueOnce({
data: validationResultsMock,
});
mocked(ejs.renderFile).mockResolvedValueOnce('report content');

const processMock = processMockFactory.build({
argv: [
Expand All @@ -83,7 +84,7 @@ describe('run', () => {
'--environment',
'DEMO',
'--outFile',
'./report/dredd/contract-tests-report',
'./report/dredd/contract-tests-report.html',
],
});

Expand All @@ -104,6 +105,10 @@ describe('run', () => {
expect(ejs.renderFile).toHaveBeenCalledWith(pathToTemplate, {
validationResults: validationResultsMock,
});
expect(fs.writeFileSync).toHaveBeenCalledWith(
'./report/dredd/contract-tests-report.html',
'report content'
);
expect(processMock.exit).not.toHaveBeenCalled();
});

Expand Down

0 comments on commit b089776

Please sign in to comment.