Files
cypress/system-tests/test/js_error_handling_spec.js
Jennifer Shehane 99b449d0a8 dependency: bump mime dependency to 3.0 (#30966)
* dependency: bump mime dep

* changelog entry

* yarn lock update

* add pending to changelog

* index on mime-dep-update: ccff6a976e add pending to changelog

* index on mime-dep-update: ccff6a976e add pending to changelog

* another removal of package

* changelog update

* index on mime-dep-update: ccff6a976e add pending to changelog

* whoops wrong issue

* fix test that was just....wrong

* Revert "fix test that was just....wrong"

This reverts commit 73ed5b0867.

* nvm, application/javascript is obsolete

* app/js to text/js updates

* downgrade to mime 3.0.0

* back to application/javascript

* index on mime-dep-update: 23cbb7783b Merge branch 'mime-dep-update' of https://github.com/cypress-io/cypress into mime-dep-update

* index on mime-dep-update: 23cbb7783b Merge branch 'mime-dep-update' of https://github.com/cypress-io/cypress into mime-dep-update

* index on mime-dep-update: 23cbb7783b Merge branch 'mime-dep-update' of https://github.com/cypress-io/cypress into mime-dep-update

---------

Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com>
Co-authored-by: AtofStryker <bglesias@gmail.com>
2025-01-30 10:41:12 -05:00

60 lines
1.4 KiB
JavaScript

const fs = require('fs')
const Fixtures = require('../lib/fixtures')
const systemTests = require('../lib/system-tests').default
const onServer = function (app) {
app.get('/index.html', (req, res) => {
return res.send(`\
<html>
<body>
some bad js a comin'
</body>
</html>\
`)
})
app.get('/gzip-bad.html', (req, res) => {
const buf = fs.readFileSync(Fixtures.path('server/gzip-bad.html.gz'))
return res.set({
'content-type': 'text/html',
'content-encoding': 'gzip',
})
.send(buf)
})
return app.get('/gzip-bad.js', (req, res) => {
const buf = fs.readFileSync(Fixtures.path('server/gzip-bad.html.gz'))
return res.set({
'content-type': 'text/javascript',
'content-encoding': 'gzip',
})
.send(buf)
})
}
describe('e2e js error handling', () => {
systemTests.setup({
servers: [{
port: 1122,
static: true,
}, {
port: 1123,
onServer,
}],
})
systemTests.it('fails', {
spec: 'js_error_handling_failing.cy.js',
snapshot: true,
expectedExitCode: 5,
onStdout (stdout) {
// firefox has a stack line for the cross-origin error that other browsers don't
return stdout
.replace(/cross-origin-script-error\s+?\(Results/, 'cross-origin-script-error\n\n (Results')
.replace(/cross-origin-script-error\s+at <unknown> \(http:\/\/localhost:1122\/static\/fail\.js:0:0\)\s+?\(Results/, 'cross-origin-script-error\n\n (Results')
},
})
})