0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 09:14:46 +01:00
posthog/cypress/support/index.js
Tim Glaser bb572272ca
Improve e2e flakeyness, skip Insights spec test (#4869)
* attempt to fix toolbar flakyness

* fix dashboard flakyness

* fix flake

* add retries to components

* Try speeding up build by skipping sourcemaps

* debug components

* show errors

* better error

* don't generate source map

* fix errors

* speed up component tests

* Try empty insights page

* Revert "Try empty insights page"

This reverts commit 68701b3804.

* Skip trends tests for now
2021-06-29 22:20:02 +02:00

53 lines
1.5 KiB
JavaScript

import '@cypress/react/support'
import 'givens/setup'
import './commands'
import { unmount } from '@cypress/react'
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('cypress-terminal-report/src/installLogsCollector')()
} catch {}
beforeEach(() => {
if (Cypress.spec.specType === 'component') {
// Freeze time to 2021.01.05 Noon UTC - this should be the same date regardless of timezone.
cy.clock(1578225600000, ['Date'])
} else {
if (Cypress.spec.name.includes('Premium')) {
cy.visit('/login?next=/?no-preloaded-app-context=true')
cy.intercept('/api/users/@me/', { fixture: 'api/user-enterprise' })
cy.login()
} else {
cy.visit('/')
cy.url().then((url) => {
if (url.includes('login')) {
cy.login()
}
})
}
}
})
beforeEach(() => {
if (Cypress.spec.specType !== 'component') {
// Make sure the insights page is actually loaded before running tests
cy.get('.insights-page').should('exist')
}
})
afterEach(() => {
if (Cypress.spec.specType === 'component') {
unmount()
}
})
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
}
})