Files
cypress/system-tests/test/cy_origin_error_spec.ts
Bill Glesias f3b67666a5 fix: update cypress to Typescript 5 (#29568)
* fix: update the monorepo to typescript 5

* chore: updating v8 snapshot cache

* chore: updating v8 snapshot cache

* chore: updating v8 snapshot cache

* run ci to see problems [run ci]

* update vue-tsc and typings that conflict with update

* regen snapshot

* fix typescript errors ui test as stack trace behavior has changed

* fix server unit tests

* update cy.origin() spec based on stack traces and code frames

* update spec to include source map url

* run ci

* fix check-ts

* chore: fix system tests [run ci]

* add preprocessor tests to batteries included to exercise new logic

* run ci

* refactor unit tests to be a bit more dry

* pin typescript to ~5.4 and adjust config to ignroe deprecations but keep importsNotUsedAsValues

* add changelog entry

* add fixme issue to stack trace mismatches inside evaled context

* use import type webpack as webpack as a lib isn't actually invboked in the runner webpack config

* fix system test as adding 4 lines of comments impacts the stack trace line 4 lines (duh)

---------

Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com>
2024-06-04 19:17:38 -04:00

56 lines
1.8 KiB
TypeScript

import path from 'path'
import systemTests, { expect } from '../lib/system-tests'
import Fixtures from '../lib/fixtures'
const e2ePath = Fixtures.projectPath('e2e')
const PORT = 3500
const onServer = function (app) {
app.get('/secondary_origin.html', (_, res) => {
res.sendFile(path.join(e2ePath, 'secondary_origin.html'))
})
}
const commonConfig = {
hosts: {
'*.foobar.com': '127.0.0.1',
},
e2e: {
experimentalOriginDependencies: true,
},
}
// TODO: This is probably more appropriate for a cy-in-cy test
// https://github.com/cypress-io/cypress/issues/20973
describe('e2e cy.origin errors', () => {
systemTests.setup({
servers: [{
port: 4466,
onServer,
}],
})
systemTests.it('captures the stack trace correctly for errors in cross origins to point users to their "cy.origin" callback', {
browser: '!webkit', // TODO(webkit): fix+unskip (needs multidomain support)
// keep the port the same to prevent issues with the snapshot
port: PORT,
spec: 'cy_origin_error.cy.ts',
expectedExitCode: 2,
config: commonConfig,
async onRun (exec) {
const { stdout } = await exec()
expect(stdout).to.contain('AssertionError')
expect(stdout).to.contain('Timed out retrying after 1ms: Expected to find element: `#doesnotexist`, but never found it.')
// FIXME: @see https://github.com/cypress-io/cypress/issues/29614
// projects using Typescript 5 do not calculate the userInvocationStack correctly,
// leading to a small mismatch when linking stack traces back to the user's IDE from
// the command log.
// check to make sure stack trace contains the 'cy.origin' source
expect(stdout).to.contain('webpack://e2e/./cypress/e2e/cy_origin_error.cy.ts:16')
expect(stdout).to.contain('webpack://e2e/./cypress/e2e/cy_origin_error.cy.ts:34')
},
})
})