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
10 changes: 1 addition & 9 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,7 @@ const config: Config.InitialOptions = {
'<rootDir>/tests/js/setupFramework.ts',
],
testMatch: testMatch || ['<rootDir>/(static|tests/js)/**/?(*.)+(spec|test).[jt]s?(x)'],
testPathIgnorePatterns: [
'<rootDir>/tests/sentry/lang/javascript/',
// ESM-style helper scripts (e.g. scripts/genPlatformProductInfo.ts use
// `const __dirname = path.dirname(fileURLToPath(import.meta.url))`) that
// SWC's CJS transform redeclares — collides with Node's module wrapper.
// None of these are tests; keep them out of Jest's discovery entirely.
'<rootDir>/scripts/',
],
modulePathIgnorePatterns: ['<rootDir>/scripts/'],
testPathIgnorePatterns: ['<rootDir>/tests/sentry/lang/javascript/'],

unmockedModulePathPatterns: [
'<rootDir>/node_modules/react',
Expand Down
14 changes: 10 additions & 4 deletions scripts/extractFormFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ import {fileURLToPath} from 'node:url';

import * as ts from 'typescript';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Named THIS_FILE / THIS_DIR rather than the conventional __filename /
// __dirname so SWC's CJS transform (used by Jest) doesn't emit a
// `const __dirname = ...` that collides with the wrapper-provided
// binding and crashes the frontend test run with a SyntaxError.
// Behavior-equivalent at runtime — the originals only shadowed the
// wrapper inside this module.
const THIS_FILE = fileURLToPath(import.meta.url);
const THIS_DIR = path.dirname(THIS_FILE);

interface ExtractedField {
formId: string;
Expand Down Expand Up @@ -480,14 +486,14 @@ ${registryEntries}

// Main execution
try {
const configPath = path.join(__dirname, '../tsconfig.json');
const configPath = path.join(THIS_DIR, '../tsconfig.json');
const extractor = new FormFieldExtractor(configPath);

console.log('🔍 Extracting form fields from TypeScript files...');
const fields = extractor.extractAllFields();

const outputPath = path.join(
__dirname,
THIS_DIR,
'../static/app/components/core/form/generatedFieldRegistry.ts'
);

Expand Down
9 changes: 7 additions & 2 deletions scripts/genPlatformProductInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ import {fileURLToPath} from 'node:url';
import * as ts from 'typescript';
import {parse as parseYaml} from 'yaml';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const SENTRY_ROOT = path.resolve(__dirname, '..');
// Named THIS_DIR rather than __dirname so SWC's CJS transform (used by Jest)
// doesn't emit a `const __dirname = ...` that collides with the wrapper-
// provided binding and crashes the whole frontend test run with a
// SyntaxError. The original `__dirname` only shadowed the wrapper inside
// this module anyway, so the rename is behavior-equivalent at runtime.
const THIS_DIR = path.dirname(fileURLToPath(import.meta.url));
const SENTRY_ROOT = path.resolve(THIS_DIR, '..');
const DOCS_ROOT = process.env.SENTRY_DOCS_PATH
? path.resolve(process.env.SENTRY_DOCS_PATH)
: path.resolve(SENTRY_ROOT, '..', 'sentry-docs');
Expand Down
Loading