-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use average of durations when merging (#163)
- Loading branch information
Showing
2 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const { mergeSplitTimings } = require('../../src/timings') | ||
|
||
chai.config.truncateThreshold = 500 | ||
|
||
it('averages the durations', () => { | ||
const timings1 = { | ||
durations: [ | ||
{ | ||
spec: 'cypress/integration/A.ts', | ||
duration: 100, | ||
}, | ||
{ | ||
spec: 'cypress/integration/B.ts', | ||
duration: 80, | ||
}, | ||
], | ||
} | ||
const timings2 = { | ||
durations: [ | ||
{ | ||
spec: 'cypress/integration/A.ts', | ||
duration: 80, | ||
}, | ||
{ | ||
spec: 'cypress/integration/B.ts', | ||
duration: 100, | ||
}, | ||
], | ||
} | ||
const merged = mergeSplitTimings([timings1, timings2]) | ||
// the results are average | ||
expect(merged).to.deep.equal({ | ||
durations: [ | ||
{ | ||
spec: 'cypress/integration/A.ts', | ||
duration: 90, | ||
}, | ||
{ | ||
spec: 'cypress/integration/B.ts', | ||
duration: 90, | ||
}, | ||
], | ||
}) | ||
}) | ||
|
||
it('takes existing values', () => { | ||
const timings1 = { | ||
durations: [ | ||
{ | ||
spec: 'cypress/integration/A.ts', | ||
duration: 100, | ||
}, | ||
], | ||
} | ||
const timings2 = { | ||
durations: [ | ||
{ | ||
spec: 'cypress/integration/B.ts', | ||
duration: 20, | ||
}, | ||
], | ||
} | ||
const merged = mergeSplitTimings([timings1, timings2]) | ||
// the result has both entries | ||
expect(merged).to.deep.equal({ | ||
durations: [ | ||
{ | ||
spec: 'cypress/integration/A.ts', | ||
duration: 100, | ||
}, | ||
{ | ||
spec: 'cypress/integration/B.ts', | ||
duration: 20, | ||
}, | ||
], | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters