2021-02-09 16:28:01 +01:00
|
|
|
import 'givens/setup'
|
2020-05-19 20:48:10 +02:00
|
|
|
import './commands'
|
|
|
|
|
2021-02-09 16:28:01 +01:00
|
|
|
try {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
require('cypress-terminal-report/src/installLogsCollector')()
|
|
|
|
} catch {}
|
2020-08-11 10:52:43 +02:00
|
|
|
|
2021-10-15 12:47:06 +02:00
|
|
|
// Add console errors into cypress logs. This helps with failures in Github Actions which otherwise swallows them.
|
|
|
|
// From: https://github.com/cypress-io/cypress/issues/300#issuecomment-688915086
|
|
|
|
Cypress.on('window:before:load', (win) => {
|
|
|
|
cy.spy(win.console, 'error')
|
|
|
|
cy.spy(win.console, 'warn')
|
|
|
|
})
|
|
|
|
|
2020-05-19 20:48:10 +02:00
|
|
|
beforeEach(() => {
|
2022-04-02 18:35:14 +02:00
|
|
|
if (Cypress.spec.name.includes('Premium')) {
|
|
|
|
cy.intercept('/api/users/@me/', { fixture: 'api/user-enterprise' })
|
2020-05-19 20:48:10 +02:00
|
|
|
|
2022-04-02 18:35:14 +02:00
|
|
|
cy.request('POST', '/api/login/', {
|
|
|
|
email: 'test@posthog.com',
|
|
|
|
password: '12345678',
|
|
|
|
})
|
|
|
|
cy.visit('/?no-preloaded-app-context=true')
|
|
|
|
} else {
|
|
|
|
cy.request('POST', '/api/login/', {
|
|
|
|
email: 'test@posthog.com',
|
|
|
|
password: '12345678',
|
|
|
|
})
|
|
|
|
cy.visit('/insights')
|
|
|
|
cy.get('.saved-insights').should('exist')
|
2021-02-09 16:28:01 +01:00
|
|
|
}
|
2020-05-19 20:48:10 +02:00
|
|
|
})
|
|
|
|
|
2021-06-29 22:20:02 +02:00
|
|
|
const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
|
|
|
|
Cypress.on('uncaught:exception', (err) => {
|
|
|
|
/* returning false here prevents Cypress from failing the test */
|
|
|
|
if (resizeObserverLoopErrRe.test(err.message)) {
|
|
|
|
return false
|
|
|
|
}
|
2020-05-19 20:48:10 +02:00
|
|
|
})
|