forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresources.cy-spec.js
More file actions
40 lines (32 loc) · 1.16 KB
/
resources.cy-spec.js
File metadata and controls
40 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/// <reference types="cypress" />
import React from 'react'
import App from './App'
import { mount } from '@cypress/react'
// NOTE: This doesn't work for some reason, but the font and svg is loading properly
describe.skip('static resources', () => {
const findResource = (name) => {
console.log(window.document)
return window.performance
.getEntriesByType('resource')
.find((item) => item.name.endsWith(name))
}
it('loads SVG', () => {
// checking if a static resource like a font has loaded
// based on the recipe "Waiting for static resource"
// https://github.com/cypress-io/cypress-example-recipes#testing-the-dom
mount(<App />)
// use wrap + .should() to retry the callback function
cy.wrap().should(() => {
const foundResource = findResource('logo.svg')
expect(foundResource).to.have.property('initiatorType', 'img')
})
})
it('loads font', () => {
// https://github.com/bahmutov/@cypress/react/issues/284
mount(<App />)
cy.wrap().should(() => {
const foundResource = findResource('Inter-Regular.woff')
expect(foundResource).to.have.property('initiatorType', 'css')
})
})
})