Skip to content

Commit

Permalink
wat
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Oct 17, 2024
1 parent 5eaa5f1 commit 33dcc0e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
33 changes: 23 additions & 10 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
{
"presets": ["@babel/env", ["@babel/typescript", { "jsxPragma": "h" }]],
"plugins": [
"@babel/plugin-transform-nullish-coalescing-operator",
[
"@babel/transform-react-jsx",
{
"runtime": "automatic",
"importSource": "preact"
}
]
"presets": [
[
"@babel/env",
{
"targets": ">0.5%, last 2 versions, Firefox ESR, not dead"
}
],
[
"@babel/typescript",
{
"jsxPragma": "h"
}
]
],
"plugins": [
"@babel/plugin-transform-nullish-coalescing-operator",
[
"@babel/transform-react-jsx",
{
"runtime": "automatic",
"importSource": "preact"
}
]
]
}
14 changes: 10 additions & 4 deletions src/__tests__/posthog-core.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defaultPostHog } from './helpers/posthog-instance'
const mockReferrerGetter = jest.fn()
const mockURLGetter = jest.fn()

import type { PostHogConfig } from '../types'
import { uuidv7 } from '../uuidv7'

const mockReferrerGetter = jest.fn()
const mockURLGetter = jest.fn()
jest.mock('../utils/globals', () => {
const orig = jest.requireActual('../utils/globals')
return {
Expand All @@ -29,7 +29,13 @@ jest.mock('../utils/globals', () => {
})

describe('posthog core', () => {
beforeEach(() => {
let defaultPostHog: typeof import('./helpers/posthog-instance').defaultPostHog
beforeEach(async () => {
// delay the import to ensure the mocks are set up before being accessed
// @ts-expect-error - allow dynamic imports
const posthogModule = await import('./helpers/posthog-instance')
defaultPostHog = posthogModule.defaultPostHog

mockReferrerGetter.mockReturnValue('https://referrer.com')
mockURLGetter.mockReturnValue('https://example.com')
console.error = jest.fn()
Expand Down

0 comments on commit 33dcc0e

Please sign in to comment.