I want to check every <script> tag in an HTML document using Cypress to make sure the src attribute matches the string '^js'.
<script src="js/somejsfile.js">
matches
<script src="somejsfile.js">
does not match.
I've tried
cy.document()
.get('head script')
.each(($match) => {
cy.wrap($match)
.invoke('attr', 'src')
.then((src) => {
expect(src).to.match(/^js/)
})
})
but src is always undefined.