mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-03 20:40:00 -05:00
* MM-61893 Replace usage of hasOwnProperty with Object.hasOwn * Update type guard in messageToElement * Replace a couple more hasOwnProperty calls
29 lines
1,006 B
JavaScript
29 lines
1,006 B
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
export function reportBenchmarkResults(cy, win) {
|
|
const testName = getTestName();
|
|
const selectors = win.getSortedTrackedSelectors();
|
|
win.dumpTrackedSelectorsStatistics();
|
|
cy.log(selectors.length);
|
|
cy.writeFile(`tests/integration/benchmark/__benchmarks__/${testName}.json`, JSON.stringify(selectors));
|
|
}
|
|
|
|
// From https://github.com/cypress-io/cypress/issues/2972#issuecomment-577072392
|
|
function getTestName() {
|
|
const cypressContext = Cypress.mocha.getRunner().suite.ctx.test;
|
|
const testTitles = [];
|
|
|
|
function extractTitles(obj) {
|
|
if (Object.hasOwn(obj, 'parent')) {
|
|
testTitles.push(obj.title);
|
|
const nextObj = obj.parent;
|
|
extractTitles(nextObj);
|
|
}
|
|
}
|
|
|
|
extractTitles(cypressContext);
|
|
const orderedTitles = testTitles.reverse();
|
|
const fileName = orderedTitles.join(' -- ');
|
|
return fileName;
|
|
}
|