Skip to content

Commit

Permalink
Skip asset copying and report render when html=false (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgruber authored Apr 18, 2018
1 parent 033fbf6 commit b97fc41
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# mochawesome-report-generator changelog

## Unreleased
### Fixed
- Skip copying assets and rendering HTML when `html` option is `false` [mochawesome #237](https://github.com/adamgruber/mochawesome/issues/237)

## [3.1.1] / 2018-01-28
### Added
Expand Down
5 changes: 5 additions & 0 deletions lib/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ function prepare(reportData, opts) {
// Get the options
const reportOptions = getOptions(opts);

// Stop here if we're not generating an HTML report
if (!reportOptions.saveHtml) {
return { reportOptions };
}

// Get the assets
const assets = getAssets(reportOptions);

Expand Down
12 changes: 12 additions & 0 deletions test/spec/lib/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ describe('lib/main', () => {
return expect(promise).to.become([ null, expectedJsonFile ]);
});

it('does not copy assets when saving only json', () => {
opts.saveHtml = false;
opts.saveJson = true;
const expectedJsonFile = path.resolve(process.cwd(), 'test', 'test.json');
outputFileStub
.onCall(0).resolves('')
.onCall(1).resolves(expectedJsonFile);
return mareport.create(testData, opts).then(() => {
expect(copySyncStub.called).to.equal(false);
});
});

it('saves html and json', () => {
opts.saveJson = true;
const expectedHtmlFile = path.resolve(process.cwd(), 'test', 'test.html');
Expand Down

0 comments on commit b97fc41

Please sign in to comment.