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

feat(persister): Add disableSortingHarEntries option #321

Merged
merged 3 commits into from
Mar 31, 2020

Conversation

offirgolan
Copy link
Collaborator

Description

When disabled, entries in the the final HAR will be sorted by the request's timestamp.
This is done by default to satisfy the HAR 1.2 spec but can be enabled to improve
diff readability when committing recordings to git.

Motivation and Context

Related to #269.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My code follows the code style of this project.
  • My commits and the title of this PR follow the Conventional Commits Specification.
  • I have read the contributing guidelines.

When disabled, entries in the the final HAR will be sorted by the request's timestamp.
This is done by default to satisfy the HAR 1.2 spec but can be enabled to improve
diff readability when committing recordings to git.
expect(har).to.be.an('object');
expect(har.log.entries).to.have.lengthOf(4);
expect(har.log.entries[0].request.url).to.include(orderedRecordUrl(3));
expect(har.log.entries[1].request.url).to.include(orderedRecordUrl(4));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Due to the way we are adding entries, we add new ones to the beginning of the array and then keep only the unique ones (due to how _.uniqWith works), new entries will be at the top of the file instead of at the bottom.

@@ -241,6 +241,25 @@ polly.configure({
});
```

### disableSortingHarEntries
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me know if you have a better name for this option @jasonmit

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a good name for the option 👍

@offirgolan offirgolan merged commit 0003c0e into master Mar 31, 2020
@offirgolan offirgolan deleted the option-to-disable-har-entry-sorting branch March 31, 2020 20:21
@tlands
Copy link

tlands commented Oct 5, 2021

FWIW, the description of this option doesn't make sense...

When disabled, entries in the the final HAR will be sorted by the request's timestamp

If I'm setting disableSortingHarEntries: true I would anticipate that the HAR file will not be sorted. Can anyone clarify?

@offirgolan
Copy link
Collaborator Author

@tlands you're right. I think the description is wrong. When disabled, it will not be sorted by timestamp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants