Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retain html report #3309

Conversation

gravityvi
Copy link
Member

Changes

  • Add a flag to retain HTML report across test runs
  • Default behaviour is not changed it generates different HTML reports if retain_report is set to true

Impacts

// HTML report options that will be use by html report
html_reporter: {
// retain html report across test runs
retain_report: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a flag? What would be the best scenario is that we append the timestamp in the index.html file which will be unique, as well as let us know which file has the latest report

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't change index.html as it would be used in different CI pipelines to host the HTML page. In future we would need to maintain a single index.html containing all the results from previous test runs. We need a flag to preserve the default behavior and not create breaking changes for those using HTML reporter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need a flag. The user can just define a folder_format function that will be undefined by default, in which case the current behaviour stays.

We should probably use reporter as the settings name, because we might have other options there. We can also in the future move the output_folder setting in it and have something like:

reporter: {
  output_folder: '',
  folder_format: function() {}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or it can be a function that returns the default value, as you've implemented here.


return `${fileName.join('/')}${isError ? '_ERROR' : '_FAILED'}_${dateStamp}.png`;
};

const folder_format = function({failed, errors, dateObject = new Date()} = {}) {
const dateStamp = getDateStamp(dateObject);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have this as prefix, as it will make it harder to sort the report folder names.

@gravityvi gravityvi marked this pull request as ready for review July 30, 2022 14:51
@gravityvi
Copy link
Member Author

default output_folder would is now moved inside reporter_options however output_folder provided directly under config would also be considered.

If folder_format is provided Nightwatch would retain HTML reports across test runs. For example

// nightwatch.conf.js
{ 
 reporter_options: {
    output_folder: 'test_outputs',
    folder_format: () => Date.now()
 }
}

@beatfactor beatfactor merged commit ffb425a into nightwatchjs:main Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retain HTML report across test runs
3 participants