Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 7357392

Browse files
Merge pull request #902 from Bandwidth/DX-2857
DX-2857 Cypress Performance Tests
2 parents 18eb0c8 + bc3a07c commit 7357392

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {performanceTester} from '../../utils/utils'
2+
3+
context('Home Page Performance Test', () => {
4+
performanceTester('/', 'Bandwidth Developer Documentation')
5+
})
6+
7+
context('Docs Page Performance Test', () => {
8+
performanceTester('/docs/', 'Bandwidth API Documentation')
9+
})
10+
11+
context('API Reference Page Performance Test', () => {
12+
performanceTester('/apis/', 'API Reference')
13+
})
14+
15+
// context('Numbers API Performance Test', () => {
16+
// performanceTester('/apis/numbers/', 'Response samples', 'h3', 10000)
17+
// })
18+
19+
// context('Global API Performance Test', () => {
20+
// performanceTester('/apis/global/', 'Access', 'h2', 10000)
21+
// })

site/cypress/utils/utils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ export const navTester = (path) => {
4747
})
4848
}
4949

50+
export const performanceTester = (path, text, element = 'h1', waitTime = 5000) => {
51+
it('measures page load on the home page', () => {
52+
cy.visit(`${path}`, {
53+
onBeforeLoad: (win) => {
54+
win.performance.mark('startMark');
55+
}
56+
})
57+
.its('performance').then((performance) => {
58+
cy.get(`${element}`).should('include.text', `${text}`)
59+
.then(() => performance.mark('endMark'))
60+
.then(() => {
61+
performance.measure('pageLoad', 'startMark', 'endMark');
62+
const measure = performance.getEntriesByName('pageLoad')[0];
63+
assert.isAtMost(measure.duration, waitTime);
64+
});
65+
});
66+
});
67+
}
68+
5069
export const testSvgLink = (path, svg, testPath) => {
5170
beforeEach(() => {
5271
cy.visit(`${path}`)

0 commit comments

Comments
 (0)