Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/lib/programs/__tests__/error-tracking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ describe('error-tracking project picker report', () => {
});

describe('error-tracking ciPreRun', () => {
test('stops when no framework is detected', async () => {
vi.mocked(detectFramework).mockResolvedValue(undefined);
const session = {
installDir: '/tmp/error-tracking-ci',
frameworkContext: {},
} as unknown as WizardSession;

await errorTrackingConfig.ciPreRun?.(session);

expect(wizardAbort).toHaveBeenCalledWith(
expect.objectContaining({ code: ErrorCodes.DetectNoFramework }),
);
expect(session.integration).toBeUndefined();
expect(session.frameworkConfig).toBeUndefined();
expect(session.skillId).toBeUndefined();
});

test('stops KMP before it sets the framework', async () => {
vi.mocked(detectFramework).mockResolvedValue(Integration.kmp);
const session = {
Expand Down
6 changes: 2 additions & 4 deletions src/lib/programs/error-tracking/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { preinstallPostHogCliOnce } from '@lib/programs/shared/posthog-cli-prein
import { analytics } from '@utils/analytics';
import { wizardAbort } from '@utils/wizard-abort';
import { ErrorCodes } from '@shared/errors';
import { abortNoFrameworkDetected } from '@lib/programs/shared/abort-no-framework';

const ERROR_TRACKING_REPORT_FILE = 'posthog-error-tracking-report.md';
const ERROR_TRACKING_DOCS_URL = 'https://posthog.com/docs/error-tracking';
Expand Down Expand Up @@ -184,10 +185,7 @@ export const errorTrackingConfig: ProgramConfig = {

const integration = await detectFramework(session.installDir);
if (!integration) {
await wizardAbort({
code: ErrorCodes.DetectNoFramework,
message: 'Could not auto-detect your framework for this project.',
});
await abortNoFrameworkDetected();
return;
}
if (ERROR_TRACKING_UNSUPPORTED.has(integration)) {
Expand Down
Loading