Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
undo changes in run script
  • Loading branch information
chargome committed Feb 10, 2025
commit 1e433fcc5c479b44f59b0ee624620cb39780db72
26 changes: 4 additions & 22 deletions dev-packages/e2e-tests/run.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,21 @@
/* eslint-disable no-console */
import { spawn } from 'child_process';
import { resolve } from 'path';
import * as dotenv from 'dotenv';
import { sync as globSync } from 'glob';
import { resolve } from 'path';

import { readFileSync } from 'fs';
import { registrySetup } from './registrySetup';

const DEFAULT_DSN = 'https://username@domain/123';
const DEFAULT_SENTRY_ORG_SLUG = 'sentry-javascript-sdks';
const DEFAULT_SENTRY_PROJECT = 'sentry-javascript-e2e-tests';

interface PackageJson {
volta?: {
node?: string;
};
}

function getVoltaNodeVersion(packageJsonPath: string): string | undefined {
try {
const packageJson: PackageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
return packageJson.volta?.node;
} catch {
return undefined;
}
}

function asyncExec(
command: string,
options: { env: Record<string, string | undefined>; cwd: string; nodeVersion?: string },
): Promise<void> {
return new Promise((resolve, reject) => {
const finalCommand = options.nodeVersion ? `volta run --node ${options.nodeVersion} ${command}` : command;
const process = spawn(finalCommand, { ...options, shell: true });
const process = spawn(command, { ...options, shell: true });

process.stdout.on('data', data => {
console.log(`${data}`);
Expand Down Expand Up @@ -95,13 +78,12 @@ async function run(): Promise<void> {

for (const testAppPath of testAppPaths) {
const cwd = resolve('test-applications', testAppPath);
const nodeVersion = getVoltaNodeVersion(resolve(cwd, 'package.json'));

console.log(`Building ${testAppPath}...`);
await asyncExec('pnpm test:build', { env, cwd, nodeVersion });
await asyncExec('pnpm test:build', { env, cwd });

console.log(`Testing ${testAppPath}...`);
await asyncExec('pnpm test:assert', { env, cwd, nodeVersion });
await asyncExec('pnpm test:assert', { env, cwd });
}
} catch (error) {
console.error(error);
Expand Down
Loading