Files
cypress/system-tests/test/js_error_handling_spec.js
T
Jessica Sachs a045e4f59a chore: move server e2e tests to system-tests (#16354)
Co-authored-by: Brian Mann <brian.mann86@gmail.com>
Co-authored-by: Zach Bloomquist <git@chary.us>
Co-authored-by: Zach Bloomquist <github@chary.us>
2021-10-18 19:53:14 +00:00

63 lines
1.5 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': 'application/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_spec.js',
snapshot: true,
expectedExitCode: 5,
config: {
video: false,
},
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')
},
})
})