0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 00:46:45 +01:00
posthog/test-runner-jest-environment.js
Sandy Spicer cf6ae8a777
feat: query loading bars (#22298)
* printing results

* sleep each row

* in progress

* returning loading status for single queries

* cluster all

* new schema

* working row counts

* change types and store in redis

* loading

* working redis

* include and exclude

* object creation

* nan

* Move some things around

* WIP: loading bar

* WIP: loading bar

* summary

* add better formatting

* hooked up

* add feature flag

* fix numbers

* fix nan

* multiple queries

* gate backend

* remove sleep and print

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (1)

* python typing

* dom props

* Update UI snapshots for `chromium` (1)

* validate

* fix test

* bunch of bugfixes

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (1)

* backend test

* remove stories

* fix type issues

* Update UI snapshots for `chromium` (2)

---------

Co-authored-by: Alexander Spicer <aspicer@surfer-172-30-3-221-hotspot.internet-for-guests.com>
Co-authored-by: timgl <tim@posthog.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-05-16 10:11:26 +01:00

31 lines
1.1 KiB
JavaScript

const { setupPage } = require('@storybook/test-runner')
const PlaywrightEnvironment = require('jest-playwright-preset/lib/PlaywrightEnvironment').default
class CustomEnvironment extends PlaywrightEnvironment {
async setup() {
await super.setup()
await setupPage(this.global.page, this.global.context)
}
async teardown() {
await super.teardown()
}
async handleTestEvent(event) {
if (event.name === 'test_done' && event.test.errors.length > 0) {
// Take screenshots on test failures - these become Actions artifacts
const parentName = event.test.parent.parent.name.replace(/\W/g, '-').toLowerCase()
const specName = event.test.parent.name.replace(/\W/g, '-').toLowerCase()
await this.global.page
.locator('body, main')
.last()
.screenshot({
path: `frontend/__snapshots__/__failures__/${parentName}--${specName}.png`,
})
}
await super.handleTestEvent(event)
}
}
module.exports = CustomEnvironment