diff --git a/.github/CANARY_FAILURE_TEMPLATE.md b/.github/CANARY_FAILURE_TEMPLATE.md index 49461065bd34..d52932b93fc3 100644 --- a/.github/CANARY_FAILURE_TEMPLATE.md +++ b/.github/CANARY_FAILURE_TEMPLATE.md @@ -1,5 +1,5 @@ --- -title: Canary tests failed -labels: 'Status: Untriaged, Type: Tests' +title: '{{ env.TITLE }}' +labels: 'Type: Tests' --- Canary tests failed: {{ env.RUN_LINK }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 438c7152defa..696ae9310d11 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,6 +43,7 @@ env: ${{ github.workspace }}/packages/utils/esm BUILD_CACHE_KEY: ${{ github.event.inputs.commit || github.sha }} + BUILD_CACHE_TARBALL_KEY: tarball-${{ github.event.inputs.commit || github.sha }} # GH will use the first restore-key it finds that matches # So it will start by looking for one from the same branch, else take the newest one it can find elsewhere @@ -729,20 +730,82 @@ jobs: cd packages/remix yarn test:integration:ci + job_e2e_prepare: + name: Prepare E2E tests + if: + (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && + github.actor != 'dependabot[bot]' + needs: [job_get_metadata, job_build] + runs-on: ubuntu-20.04 + timeout-minutes: 15 + steps: + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + uses: actions/checkout@v3 + with: + ref: ${{ env.HEAD_COMMIT }} + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version-file: 'package.json' + - name: Restore caches + uses: ./.github/actions/restore-cache + env: + DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }} + - name: Check tarball cache + uses: actions/cache@v3 + with: + path: ${{ github.workspace }}/packages/*/*.tgz + key: ${{ env.BUILD_CACHE_TARBALL_KEY }} + - name: Build tarballs + run: yarn build:tarball + job_e2e_tests: - name: E2E (Shard ${{ matrix.shard }}) Tests + name: E2E ${{ matrix.label || matrix.test-application }} Test # We only run E2E tests for non-fork PRs because the E2E tests require secrets to work and they can't be accessed from forks # Dependabot PRs sadly also don't have access to secrets, so we skip them as well if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]' - needs: [job_get_metadata, job_build] + needs: [job_get_metadata, job_build, job_e2e_prepare] runs-on: ubuntu-20.04 - timeout-minutes: 30 + timeout-minutes: 10 + env: + E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }} + E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} + # Needed because some apps expect a certain prefix + NEXT_PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} + PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} + REACT_APP_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} + E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks' + E2E_TEST_SENTRY_TEST_PROJECT: 'sentry-javascript-e2e-tests' strategy: fail-fast: false matrix: - shard: [1, 2, 3, 4] + test-application: + [ + 'node-express-app', + 'create-react-app', + 'create-next-app', + 'create-remix-app', + 'nextjs-app-dir', + 'react-create-hash-router', + 'standard-frontend-react', + 'standard-frontend-react-tracing-import', + 'sveltekit', + ] + build-command: + - false + label: + - false + # Add any variations of a test app here + # You should provide an alternate build-command as well as a matching label + include: + - test-application: 'create-react-app' + build-command: 'test:build-ts3.8' + label: 'create-react-app (TS 3.8)' + - test-application: 'standard-frontend-react' + build-command: 'test:build-ts3.8' + label: 'standard-frontend-react (TS 3.8)' steps: - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) @@ -761,22 +824,36 @@ jobs: env: DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }} + - name: Restore tarball cache + uses: actions/cache/restore@v3 + with: + path: ${{ github.workspace }}/packages/*/*.tgz + key: ${{ env.BUILD_CACHE_TARBALL_KEY }} + - name: Get node version id: versions run: | echo "echo node=$(jq -r '.volta.node' package.json)" >> $GITHUB_OUTPUT - - name: Run E2E tests + + - name: Validate Verdaccio + run: yarn test:validate + working-directory: packages/e2e-tests + + - name: Prepare Verdaccio + run: yarn test:prepare + working-directory: packages/e2e-tests env: E2E_TEST_PUBLISH_SCRIPT_NODE_VERSION: ${{ steps.versions.outputs.node }} - E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }} - E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} - E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks' - E2E_TEST_SENTRY_TEST_PROJECT: 'sentry-javascript-e2e-tests' - E2E_TEST_SHARD: ${{ matrix.shard }} - E2E_TEST_SHARD_AMOUNT: 4 - run: | - cd packages/e2e-tests - yarn test:e2e + + - name: Build E2E app + working-directory: packages/e2e-tests/test-applications/${{ matrix.test-application }} + timeout-minutes: 5 + run: yarn ${{ matrix.build-command || 'test:build' }} + + - name: Run E2E test + working-directory: packages/e2e-tests/test-applications/${{ matrix.test-application }} + timeout-minutes: 5 + run: yarn test:assert job_required_tests: name: All required tests passed or skipped diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 3bd402dce4cf..d70c95f033e0 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -17,47 +17,123 @@ permissions: issues: write jobs: - job_canary_test: - name: Canary Tests + job_e2e_prepare: + name: Prepare E2E Canary tests runs-on: ubuntu-20.04 - timeout-minutes: 60 + timeout-minutes: 30 steps: - - name: 'Check out current commit' + - name: Check out current commit uses: actions/checkout@v3 with: ref: ${{ env.HEAD_COMMIT }} - - uses: pnpm/action-setup@v2 - with: - version: 8.3.1 - name: Set up Node uses: actions/setup-node@v3 with: node-version-file: 'package.json' + - name: Check canary cache + uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/packages/*/*.tgz + ${{ github.workspace }}/node_modules + ${{ github.workspace }}/packages/*/node_modules + key: canary-${{ env.HEAD_COMMIT }} - name: Install dependencies - run: yarn install --ignore-engines --frozen-lockfile + run: yarn install - name: Build packages run: yarn build + + - name: Build tarballs + run: yarn build:tarball + + job_e2e_tests: + name: E2E ${{ matrix.label }} Test + needs: [job_e2e_prepare] + runs-on: ubuntu-20.04 + timeout-minutes: 15 + env: + E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }} + E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} + # Needed because certain apps expect a certain prefix + NEXT_PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} + PUBLIC_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} + REACT_APP_E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} + E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks' + E2E_TEST_SENTRY_TEST_PROJECT: 'sentry-javascript-e2e-tests' + strategy: + fail-fast: false + matrix: + include: + - test-application: 'create-react-app' + build-command: 'test:build-canary' + label: 'create-react-app (canary)' + - test-application: 'nextjs-app-dir' + build-command: 'test:build-canary' + label: 'nextjs-app-dir (canary)' + - test-application: 'nextjs-app-dir' + build-command: 'test:build-latest' + label: 'nextjs-app-dir (latest)' + - test-application: 'react-create-hash-router' + build-command: 'test:build-canary' + label: 'react-create-hash-router (canary)' + - test-application: 'standard-frontend-react' + build-command: 'test:build-canary' + label: 'standard-frontend-react (canary)' + + steps: + - name: Check out current commit + uses: actions/checkout@v3 + with: + ref: ${{ env.HEAD_COMMIT }} + - uses: pnpm/action-setup@v2 + with: + version: 8.3.1 + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version-file: 'package.json' + + - name: Restore canary cache + uses: actions/cache/restore@v3 + with: + path: | + ${{ github.workspace }}/packages/*/*.tgz + ${{ github.workspace }}/node_modules + ${{ github.workspace }}/packages/*/node_modules + key: canary-${{ env.HEAD_COMMIT }} + - name: Get node version id: versions run: | echo "echo node=$(jq -r '.volta.node' package.json)" >> $GITHUB_OUTPUT - - name: Run Canary Tests + + - name: Validate Verdaccio + run: yarn test:validate + working-directory: packages/e2e-tests + + - name: Prepare Verdaccio + run: yarn test:prepare + working-directory: packages/e2e-tests env: E2E_TEST_PUBLISH_SCRIPT_NODE_VERSION: ${{ steps.versions.outputs.node }} - E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }} - E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }} - E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks' - E2E_TEST_SENTRY_TEST_PROJECT: 'sentry-javascript-e2e-tests' - CANARY_E2E_TEST: 'yes' - run: | - cd packages/e2e-tests - yarn test:e2e + + - name: Build E2E app + working-directory: packages/e2e-tests/test-applications/${{ matrix.test-application }} + timeout-minutes: 5 + run: yarn ${{ matrix.build-command }} + + - name: Run E2E test + working-directory: packages/e2e-tests/test-applications/${{ matrix.test-application }} + timeout-minutes: 5 + run: yarn test:assert + - name: Create Issue if: failure() && github.event_name == 'schedule' uses: JasonEtco/create-an-issue@e27dddc79c92bc6e4562f268fffa5ed752639abd env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RUN_LINK: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + TITLE: ${{ matrix.label }} Test Failed with: filename: .github/CANARY_FAILURE_TEMPLATE.md update_existing: true @@ -98,7 +174,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RUN_LINK: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + TITLE: Ember Canary ${{ matrix.scenario }} Test Failed with: filename: .github/CANARY_FAILURE_TEMPLATE.md update_existing: true - title: 'Ember Canary tests failed' diff --git a/packages/e2e-tests/.gitignore b/packages/e2e-tests/.gitignore index a16add542a3f..385b720a0ca2 100644 --- a/packages/e2e-tests/.gitignore +++ b/packages/e2e-tests/.gitignore @@ -1,2 +1,4 @@ .env tmp +.tmp_build_output +pnpm-lock.yaml diff --git a/packages/e2e-tests/README.md b/packages/e2e-tests/README.md index 69e4dc7a062a..cdb4a0e5ae04 100644 --- a/packages/e2e-tests/README.md +++ b/packages/e2e-tests/README.md @@ -15,6 +15,12 @@ Prerequisites: Docker yarn test:e2e ``` +Or run only a single E2E test app: + +```bash +yarn test:run +``` + ## How they work Before running any tests we launch a fake test registry (in our case [Verdaccio](https://verdaccio.org/docs/e2e/)), we @@ -43,40 +49,14 @@ cat > test-applications/my-new-test-application/.npmrc << EOF @sentry:registry=http://localhost:4873 @sentry-internal:registry=http://localhost:4873 EOF - -# Add a test recipe file to the test application -touch test-applications/my-new-test-application/test-recipe.json -``` - -To get you started with the recipe, you can copy the following into `test-recipe.json`: - -```json -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "My New Test Application", - "buildCommand": "pnpm install", - "tests": [ - { - "testName": "My new test", - "testCommand": "pnpm test", - "timeoutSeconds": 60 - } - ] -} ``` -The `test-recipe.json` files follow a schema (`e2e-tests/test-recipe-schema.json`). Here is a basic explanation of the -fields: +Make sure to add a `test:build` and `test:assert` command to the new app's `package.json` file. -- The `buildCommand` command runs only once before any of the tests and is supposed to build the test application. If - this command returns a non-zero exit code, it counts as a failed test and the test application's tests are not run. In - the example above, we use the `--pure-lockfile` flag to install dependencies without modifiying the lockfile so that - there aren't any changes in the git worktree after running the tests. -- The `testCommand` command is supposed to run tests on the test application. If the configured command returns a - non-zero exit code, it counts as a failed test. -- A test timeout can be configured via `timeoutSeconds`, it defaults to `60`. +Add the new test app to `test-application` matrix in `.github/workflows/build.yml` for the `job_e2e_tests` job. If you +want to run a canary test, add it to the `canary.yml` workflow. -**An important thing to note:** In the context of the `buildCommand` the fake test registry is available at +**An important thing to note:** In the context of the build/test commands the fake test registry is available at `http://localhost:4873`. It hosts all of our packages as if they were to be published with the state of the current branch. This means we can install the packages from this registry via the `.npmrc` configuration as seen above. If you add Sentry dependencies to your test application, you should set the dependency versions set to `latest || *` in order @@ -89,7 +69,9 @@ for it to work with both regular and prerelease versions: "version": "1.0.0", "private": true, "scripts": { - "test": "echo \"Hello world!\"" + "test": "echo \"Hello world!\"", + "test:build": "pnpm install", + "test:assert": "pnpm test" }, "dependencies": { "@sentry/node": "latest || *" diff --git a/packages/e2e-tests/lib/buildApp.ts b/packages/e2e-tests/lib/buildApp.ts deleted file mode 100644 index 426038f55b4c..000000000000 --- a/packages/e2e-tests/lib/buildApp.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* eslint-disable no-console */ - -import * as fs from 'fs-extra'; -import * as path from 'path'; - -import { DEFAULT_BUILD_TIMEOUT_SECONDS } from './constants'; -import type { Env, RecipeInstance } from './types'; -import { prefixObjectKeys, spawnAsync } from './utils'; - -export async function buildApp(appDir: string, recipeInstance: RecipeInstance, envVars: Env): Promise { - const { recipe, label, dependencyOverrides } = recipeInstance; - - const packageJsonPath = path.resolve(appDir, 'package.json'); - - if (dependencyOverrides) { - // Override dependencies - const packageJson: { dependencies?: Record } = JSON.parse( - fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }), - ); - packageJson.dependencies = packageJson.dependencies - ? { ...packageJson.dependencies, ...dependencyOverrides } - : dependencyOverrides; - fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), { - encoding: 'utf-8', - }); - } - - if (recipe.buildCommand) { - console.log(`Running build command for test application "${label}"`); - - const env = { - ...process.env, - ...envVars, - }; - - const buildResult = await spawnAsync(recipe.buildCommand, { - cwd: appDir, - timeout: (recipe.buildTimeoutSeconds ?? DEFAULT_BUILD_TIMEOUT_SECONDS) * 1000, - env: { - ...env, - ...prefixObjectKeys(env, 'NEXT_PUBLIC_'), - ...prefixObjectKeys(env, 'REACT_APP_'), - ...prefixObjectKeys(env, 'PUBLIC_'), - }, - }); - - if (buildResult.error) { - console.log(`Build failed for test application "${label}"`); - - // Prepends some text to the output build command's output so we can distinguish it from logging in this script - console.log(buildResult.stdout.replace(/^/gm, ' [BUILD OUTPUT] ')); - console.log(buildResult.stderr.replace(/^/gm, ' [BUILD OUTPUT] ')); - - console.log('[BUILD ERROR] ', buildResult.error); - throw buildResult.error; - } - - if (recipe.buildAssertionCommand) { - console.log(`Running build assertion for test application "${label}"`); - - const buildAssertionResult = await spawnAsync( - recipe.buildAssertionCommand, - { - cwd: appDir, - timeout: (recipe.buildTimeoutSeconds ?? DEFAULT_BUILD_TIMEOUT_SECONDS) * 1000, - env: { - ...env, - ...prefixObjectKeys(env, 'NEXT_PUBLIC_'), - ...prefixObjectKeys(env, 'REACT_APP_'), - }, - }, - buildResult.stdout, - ); - - if (buildAssertionResult.error) { - console.log(`Build assertion failed for test application "${label}"`); - - // Prepends some text to the output build command's output so we can distinguish it from logging in this script - console.log(buildAssertionResult.stdout.replace(/^/gm, ' [BUILD ASSERTION OUTPUT] ')); - console.log(buildAssertionResult.stderr.replace(/^/gm, ' [BUILD ASSERTION OUTPUT] ')); - - console.log('[BUILD ASSERTION ERROR] ', buildAssertionResult.error); - - throw buildAssertionResult.error; - } - } - } -} diff --git a/packages/e2e-tests/lib/constructRecipeInstances.ts b/packages/e2e-tests/lib/constructRecipeInstances.ts deleted file mode 100644 index 86dfd1ef89f2..000000000000 --- a/packages/e2e-tests/lib/constructRecipeInstances.ts +++ /dev/null @@ -1,52 +0,0 @@ -import * as fs from 'fs'; - -import type { Recipe, RecipeInput, RecipeInstance } from './types'; - -export function constructRecipeInstances(recipePaths: string[]): RecipeInstance[] { - const recipes = buildRecipes(recipePaths); - const recipeInstances: Omit[] = []; - - recipes.forEach(recipe => { - recipe.versions.forEach(version => { - const dependencyOverrides = - Object.keys(version.dependencyOverrides).length > 0 ? version.dependencyOverrides : undefined; - const dependencyOverridesInformationString = dependencyOverrides - ? ` (Dependency overrides: ${JSON.stringify(dependencyOverrides)})` - : ''; - - recipeInstances.push({ - label: `${recipe.testApplicationName}${dependencyOverridesInformationString}`, - recipe, - dependencyOverrides, - }); - }); - }); - - return recipeInstances - .map((instance, i) => ({ ...instance, portModulo: i, portGap: recipeInstances.length })) - .filter((_, i) => { - if (process.env.E2E_TEST_SHARD && process.env.E2E_TEST_SHARD_AMOUNT) { - return (i + Number(process.env.E2E_TEST_SHARD)) % Number(process.env.E2E_TEST_SHARD_AMOUNT) === 0; - } else { - return true; - } - }); -} - -function buildRecipes(recipePaths: string[]): Recipe[] { - return recipePaths.map(recipePath => buildRecipe(recipePath)); -} - -function buildRecipe(recipePath: string): Recipe { - const recipe: RecipeInput = JSON.parse(fs.readFileSync(recipePath, 'utf-8')); - - const versions = process.env.CANARY_E2E_TEST - ? recipe.canaryVersions ?? [] - : recipe.versions ?? [{ dependencyOverrides: {} }]; - - return { - ...recipe, - path: recipePath, - versions, - }; -} diff --git a/packages/e2e-tests/lib/runAllTestApps.ts b/packages/e2e-tests/lib/runAllTestApps.ts deleted file mode 100644 index d5f4c247f2e6..000000000000 --- a/packages/e2e-tests/lib/runAllTestApps.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* eslint-disable no-console */ - -import { constructRecipeInstances } from './constructRecipeInstances'; -import { buildAndTestApp } from './runTestApp'; -import type { RecipeInstance, RecipeTestResult } from './types'; - -export async function runAllTestApps( - recipePaths: string[], - envVarsToInject: Record, -): Promise { - const maxParallel = process.env.CANARY_E2E_TEST - ? 1 // TODO: figure out why concurrent tests fail for Next.js and remove this concurrency limitation - : process.env.CI - ? 3 - : 6; - - const recipeInstances = constructRecipeInstances(recipePaths); - - const results = await shardPromises( - recipeInstances, - recipeInstance => buildAndTestApp(recipeInstance, envVarsToInject), - maxParallel, - ); - - console.log('--------------------------------------'); - console.log('Test Result Summary:'); - - results.forEach(result => { - if (result.buildFailed) { - console.log(`● BUILD FAILED - ${result.label} (${result.recipe.path}`); - } else { - console.log(`● BUILD SUCCEEDED - ${result.label}`); - result.tests.forEach(testResult => { - console.log(` ● ${testResult.result.padEnd(7, ' ')} ${testResult.testName}`); - }); - } - }); - - const failed = results.filter(result => result.buildFailed || result.testFailed); - - if (failed.length) { - console.log(`${failed.length} test(s) failed.`); - process.exit(1); - } - - console.log('All tests succeeded. 🎉'); -} - -// Always run X promises at a time -function shardPromises( - recipes: RecipeInstance[], - callback: (recipe: RecipeInstance) => Promise, - maxParallel: number, -): Promise { - return new Promise(resolve => { - console.log(`Running a total of ${recipes.length} jobs, with up to ${maxParallel} jobs in parallel...`); - const results: RecipeTestResult[] = []; - const remaining = recipes.slice(); - const running: Promise[] = []; - - function runNext(): void { - if (running.length < maxParallel && remaining.length > 0) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const next = remaining.shift()!; - const promise = callback(next); - - console.log(`Running job ${next.label}, ${remaining.length} remaining...`); - - running.push(promise); - - promise - .then(result => results.push(result)) - .finally(() => { - const pos = running.indexOf(promise); - running.splice(pos, 1); - - runNext(); - }); - } else if (remaining.length === 0 && running.length === 0) { - resolve(results); - } - } - - // Initial runs - for (let i = 0; i < maxParallel; i++) { - runNext(); - } - }); -} diff --git a/packages/e2e-tests/lib/runTestApp.ts b/packages/e2e-tests/lib/runTestApp.ts deleted file mode 100644 index 0d58757d3e35..000000000000 --- a/packages/e2e-tests/lib/runTestApp.ts +++ /dev/null @@ -1,58 +0,0 @@ -import * as fs from 'fs'; -import * as fsExtra from 'fs-extra'; -import * as path from 'path'; - -import { buildApp } from './buildApp'; -import { testApp } from './testApp'; -import type { Env, RecipeInstance, RecipeTestResult } from './types'; - -// This should never throw, we always return a result here -export async function buildAndTestApp( - recipeInstance: RecipeInstance, - envVarsToInject: Record, -): Promise { - const { recipe, portModulo, portGap } = recipeInstance; - const recipeDirname = path.dirname(recipe.path); - - const tmpFolder = path.join(__dirname, '..', 'tmp'); - await fs.promises.mkdir(tmpFolder, { recursive: true }); - const targetDir = await fs.promises.mkdtemp( - path.join(tmpFolder, `${recipeInstance.recipe.testApplicationName}-${Date.now()}-`), - ); - - await fsExtra.copy(recipeDirname, targetDir); - - const env: Env = { - ...envVarsToInject, - PORT_MODULO: portModulo.toString(), - PORT_GAP: portGap.toString(), - }; - - try { - await buildApp(targetDir, recipeInstance, env); - } catch (error) { - await fsExtra.remove(targetDir); - - return { - ...recipeInstance, - buildFailed: true, - testFailed: false, - tests: [], - }; - } - - // This cannot throw, we always return a result here - return testApp(targetDir, recipeInstance, env) - .finally(() => { - // Cleanup - void fsExtra.remove(targetDir); - }) - .then(results => { - return { - ...recipeInstance, - buildFailed: false, - testFailed: results.some(result => result.result !== 'PASS'), - tests: results, - }; - }); -} diff --git a/packages/e2e-tests/lib/testApp.ts b/packages/e2e-tests/lib/testApp.ts deleted file mode 100644 index 02743c26f633..000000000000 --- a/packages/e2e-tests/lib/testApp.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* eslint-disable no-console */ - -import { DEFAULT_TEST_TIMEOUT_SECONDS } from './constants'; -import type { Env, RecipeInstance, TestDef, TestResult } from './types'; -import { prefixObjectKeys, spawnAsync } from './utils'; - -export async function testApp(appDir: string, recipeInstance: RecipeInstance, env: Env): Promise { - const { recipe } = recipeInstance; - - const results: TestResult[] = []; - for (const test of recipe.tests) { - results.push(await runTest(appDir, recipeInstance, test, env)); - } - - return results; -} - -async function runTest( - appDir: string, - recipeInstance: RecipeInstance, - test: TestDef, - envVars: Env, -): Promise { - const { recipe, label } = recipeInstance; - console.log(`Running test command for test application "${label}", test "${test.testName}"`); - - const env = { - ...process.env, - ...envVars, - }; - - const testResult = await spawnAsync(test.testCommand, { - cwd: appDir, - timeout: (recipe.testTimeoutSeconds ?? DEFAULT_TEST_TIMEOUT_SECONDS) * 1000, - env: { - ...env, - ...prefixObjectKeys(env, 'NEXT_PUBLIC_'), - ...prefixObjectKeys(env, 'REACT_APP_'), - }, - }); - - if (testResult.error) { - console.log(`Test failed for test application "${label}", test "${test.testName}"`); - - // Prepends some text to the output test command's output so we can distinguish it from logging in this script - console.log(testResult.stdout.replace(/^/gm, ' [TEST OUTPUT] ')); - console.log(testResult.stderr.replace(/^/gm, ' [TEST OUTPUT] ')); - - console.log('[TEST ERROR] ', testResult.error); - - return { - testName: test.testName, - result: testResult.error?.message.includes('ETDIMEDOUT') ? 'TIMEOUT' : 'FAIL', - }; - } - - return { - testName: test.testName, - result: 'PASS', - }; -} diff --git a/packages/e2e-tests/lib/types.ts b/packages/e2e-tests/lib/types.ts deleted file mode 100644 index f06094ce0426..000000000000 --- a/packages/e2e-tests/lib/types.ts +++ /dev/null @@ -1,50 +0,0 @@ -export type TestResult = { - testName: string; - result: 'PASS' | 'FAIL' | 'TIMEOUT'; -}; - -type DependencyOverrides = Record; - -export interface TestDef { - testName: string; - testCommand: string; - timeoutSeconds?: number; -} - -export interface RecipeInput { - testApplicationName: string; - buildCommand?: string; - buildAssertionCommand?: string; - buildTimeoutSeconds?: number; - testTimeoutSeconds?: number; - tests: TestDef[]; - versions?: { dependencyOverrides: DependencyOverrides }[]; - canaryVersions?: { dependencyOverrides: DependencyOverrides }[]; -} - -export interface Recipe { - path: string; - testApplicationName: string; - buildCommand?: string; - buildAssertionCommand?: string; - buildTimeoutSeconds?: number; - testTimeoutSeconds?: number; - tests: TestDef[]; - versions: { dependencyOverrides: DependencyOverrides }[]; -} - -export interface RecipeInstance { - label: string; - recipe: Recipe; - dependencyOverrides?: DependencyOverrides; - portModulo: number; - portGap: number; -} - -export interface RecipeTestResult extends RecipeInstance { - buildFailed: boolean; - testFailed: boolean; - tests: TestResult[]; -} - -export type Env = Record; diff --git a/packages/e2e-tests/lib/utils.ts b/packages/e2e-tests/lib/utils.ts deleted file mode 100644 index ef6d65dc84dc..000000000000 --- a/packages/e2e-tests/lib/utils.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* eslint-disable no-console */ -import * as childProcess from 'child_process'; - -// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message -export function printCIErrorMessage(message: string): void { - if (process.env.CI) { - console.log(`::error::${message}`); - } else { - console.log(message); - } -} - -interface SpawnAsync { - stdout: string; - stderr: string; - error?: Error; - status: number | null; -} - -interface SpawnOptions { - timeout?: number; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - env?: any; - cwd?: string; -} - -export function spawnAsync(cmd: string, options?: SpawnOptions, input?: string): Promise { - const timeoutMs = options?.timeout || 60_000 * 5; - - return new Promise(resolve => { - const cp = childProcess.spawn(cmd, { shell: true, ...options }); - - // Ensure we properly time out after max. 5 min per command - let timeout: ReturnType | undefined = setTimeout(() => { - console.log(`Command "${cmd}" timed out after 5 minutes.`); - cp.kill(); - end(null, `ETDIMEDOUT: Process timed out after ${timeoutMs} ms.`); - }, timeoutMs); - - const stderr: unknown[] = []; - const stdout: string[] = []; - let error: Error | undefined; - - function end(status: number | null, errorMessage?: string): void { - // This means we already ended - if (!timeout) { - return; - } - - if (!error && errorMessage) { - error = new Error(errorMessage); - } - - clearTimeout(timeout); - timeout = undefined; - resolve({ - stdout: stdout.join(''), - stderr: stderr.join(''), - error: error || (status !== 0 ? new Error(`Process exited with status ${status}`) : undefined), - status, - }); - } - - cp.stdout.on('data', data => { - stdout.push(data ? (data as object).toString() : ''); - }); - - cp.stderr.on('data', data => { - stderr.push(data ? (data as object).toString() : ''); - }); - - cp.on('error', e => { - error = e; - }); - - cp.on('close', status => { - end(status); - }); - - if (input) { - cp.stdin.write(input); - cp.stdin.end(); - } - }); -} - -export function prefixObjectKeys( - obj: Record, - prefix: string, -): Record { - return Object.keys(obj).reduce>((result, key) => { - result[prefix + key] = obj[key]; - return result; - }, {}); -} diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index cc5f6f0e5a1a..93471552edab 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -18,13 +18,14 @@ "test:run": "ts-node run.ts", "test:validate-configuration": "ts-node validate-verdaccio-configuration.ts", "test:validate-test-app-setups": "ts-node validate-test-app-setups.ts", - "clean": "rimraf tmp test-applications/**/node_modules test-applications/**/dist" + "test:prepare": "ts-node prepare.ts", + "test:validate": "run-s test:validate-configuration test:validate-test-app-setups", + "clean": "rimraf tmp test-applications/**/{node_modules,dist,build,.next,.sveltekit,pnpm-lock.yaml}" }, "devDependencies": { "@types/glob": "8.0.0", "@types/node": "^14.6.4", "dotenv": "16.0.3", - "fs-extra": "11.1.0", "glob": "8.0.3", "ts-node": "10.9.1", "yaml": "2.2.2" diff --git a/packages/e2e-tests/prepare.ts b/packages/e2e-tests/prepare.ts new file mode 100644 index 000000000000..7fee7677bf94 --- /dev/null +++ b/packages/e2e-tests/prepare.ts @@ -0,0 +1,24 @@ +/* eslint-disable max-lines */ +/* eslint-disable no-console */ +import * as dotenv from 'dotenv'; + +import { validate } from './lib/validate'; +import { registrySetup } from './registrySetup'; + +async function run(): Promise { + // Load environment variables from .env file locally + dotenv.config(); + + if (!validate()) { + process.exit(1); + } + + try { + registrySetup(); + } catch (error) { + console.error(error); + process.exit(1); + } +} + +void run(); diff --git a/packages/e2e-tests/publish-packages.ts b/packages/e2e-tests/publish-packages.ts index fd03a777315a..4715b3258771 100644 --- a/packages/e2e-tests/publish-packages.ts +++ b/packages/e2e-tests/publish-packages.ts @@ -5,9 +5,6 @@ import * as path from 'path'; const repositoryRoot = path.resolve(__dirname, '../..'); -// Create tarballs -childProcess.execSync('yarn build:tarball', { encoding: 'utf8', cwd: repositoryRoot, stdio: 'inherit' }); - // Get absolute paths of all the packages we want to publish to the fake registry const packageTarballPaths = glob.sync('packages/*/sentry-*.tgz', { cwd: repositoryRoot, diff --git a/packages/e2e-tests/run.ts b/packages/e2e-tests/run.ts index 658b4ffaa97f..cdf400f52498 100644 --- a/packages/e2e-tests/run.ts +++ b/packages/e2e-tests/run.ts @@ -1,34 +1,52 @@ /* eslint-disable max-lines */ /* eslint-disable no-console */ +import { exec } from 'child_process'; import * as dotenv from 'dotenv'; -import * as glob from 'glob'; +import { sync as globSync } from 'glob'; +import { resolve } from 'path'; +import { promisify } from 'util'; -import { runAllTestApps } from './lib/runAllTestApps'; import { validate } from './lib/validate'; import { registrySetup } from './registrySetup'; +const asyncExec = promisify(exec); + async function run(): Promise { // Load environment variables from .env file locally dotenv.config(); + // Allow to run a single app only via `yarn test:run ` + const appName = process.argv[2]; + if (!validate()) { process.exit(1); } const envVarsToInject = { - REACT_APP_E2E_TEST_DSN: process.env.E2E_TEST_DSN, - REMIX_APP_E2E_TEST_DSN: process.env.E2E_TEST_DSN, NEXT_PUBLIC_E2E_TEST_DSN: process.env.E2E_TEST_DSN, PUBLIC_E2E_TEST_DSN: process.env.E2E_TEST_DSN, - BASE_PORT: '27496', // just some random port + REACT_APP_E2E_TEST_DSN: process.env.E2E_TEST_DSN, }; + const env = { ...process.env, ...envVarsToInject }; + try { registrySetup(); - const recipePaths = glob.sync(`${__dirname}/test-applications/*/test-recipe.json`, { absolute: true }); + const testAppPaths = appName ? [appName.trim()] : globSync('*', { cwd: `${__dirname}/test-applications/` }); + + console.log(`Runnings tests for: ${testAppPaths.join(', ')}`); + console.log(''); + + for (const testAppPath of testAppPaths) { + const cwd = resolve('test-applications', testAppPath); + + console.log(`Building ${testAppPath}...`); + await asyncExec('pnpm test:build', { env, cwd }); - await runAllTestApps(recipePaths, envVarsToInject); + console.log(`Testing ${testAppPath}...`); + await asyncExec('pnpm test:assert', { env, cwd }); + } } catch (error) { console.error(error); process.exit(1); diff --git a/packages/e2e-tests/test-applications/create-next-app/package.json b/packages/e2e-tests/test-applications/create-next-app/package.json index 2935a28b9dd3..b4f971150d8f 100644 --- a/packages/e2e-tests/test-applications/create-next-app/package.json +++ b/packages/e2e-tests/test-applications/create-next-app/package.json @@ -5,7 +5,9 @@ "scripts": { "build": "next build", "test:prod": "TEST_ENV=prod playwright test", - "test:dev": "TEST_ENV=dev playwright test" + "test:dev": "TEST_ENV=dev playwright test", + "test:build": "pnpm install && npx playwright install && pnpm build", + "test:assert": "pnpm test:prod && pnpm test:dev" }, "dependencies": { "@next/font": "13.0.7", diff --git a/packages/e2e-tests/test-applications/create-next-app/playwright.config.ts b/packages/e2e-tests/test-applications/create-next-app/playwright.config.ts index 22dddd16d7ba..dafe32a31126 100644 --- a/packages/e2e-tests/test-applications/create-next-app/playwright.config.ts +++ b/packages/e2e-tests/test-applications/create-next-app/playwright.config.ts @@ -7,7 +7,7 @@ if (!testEnv) { throw new Error('No test env defined'); } -const port = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO); +const port = 3030; /** * See https://playwright.dev/docs/test-configuration. diff --git a/packages/e2e-tests/test-applications/create-next-app/sentry.client.config.ts b/packages/e2e-tests/test-applications/create-next-app/sentry.client.config.ts index 48ca1cd7306b..760843e01739 100644 --- a/packages/e2e-tests/test-applications/create-next-app/sentry.client.config.ts +++ b/packages/e2e-tests/test-applications/create-next-app/sentry.client.config.ts @@ -9,6 +9,7 @@ Sentry.init({ dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN, // Adjust this value in production, or use tracesSampler for greater control tracesSampleRate: 1.0, + // ... // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so diff --git a/packages/e2e-tests/test-applications/create-next-app/test-recipe.json b/packages/e2e-tests/test-applications/create-next-app/test-recipe.json deleted file mode 100644 index 621c79df3cc7..000000000000 --- a/packages/e2e-tests/test-applications/create-next-app/test-recipe.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "create-next-app", - "buildCommand": "pnpm install && npx playwright install && pnpm build", - "tests": [ - { - "testName": "Playwright tests - Prod Mode", - "testCommand": "pnpm test:prod" - }, - { - "testName": "Playwright tests - Dev Mode", - "testCommand": "pnpm test:dev" - } - ] -} diff --git a/packages/e2e-tests/test-applications/create-next-app/tests/behaviour-client.test.ts b/packages/e2e-tests/test-applications/create-next-app/tests/behaviour-client.test.ts index d0ede66cf32f..8d5e94cb2f55 100644 --- a/packages/e2e-tests/test-applications/create-next-app/tests/behaviour-client.test.ts +++ b/packages/e2e-tests/test-applications/create-next-app/tests/behaviour-client.test.ts @@ -7,6 +7,7 @@ const sentryTestProject = process.env.E2E_TEST_SENTRY_TEST_PROJECT; const EVENT_POLLING_TIMEOUT = 30_000; test('Sends a client-side exception to Sentry', async ({ page }) => { + page.on('console', msg => console.log(msg.text())); await page.goto('/'); const exceptionButton = page.locator('id=exception-button'); diff --git a/packages/e2e-tests/test-applications/create-next-app/tsconfig.json b/packages/e2e-tests/test-applications/create-next-app/tsconfig.json index 7686eb53f6ac..3ff0501fdb85 100644 --- a/packages/e2e-tests/test-applications/create-next-app/tsconfig.json +++ b/packages/e2e-tests/test-applications/create-next-app/tsconfig.json @@ -12,7 +12,8 @@ "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve" + "jsx": "preserve", + "incremental": true }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "next.config.js"], "exclude": ["node_modules"] diff --git a/packages/e2e-tests/test-applications/create-react-app/package.json b/packages/e2e-tests/test-applications/create-react-app/package.json index 2ba893bc70ed..8584121f92dc 100644 --- a/packages/e2e-tests/test-applications/create-react-app/package.json +++ b/packages/e2e-tests/test-applications/create-react-app/package.json @@ -22,7 +22,11 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "test:build": "pnpm install && pnpm build", + "test:build-ts3.8": "pnpm install && pnpm add typescript@3.8 && pnpm build", + "test:build-canary": "pnpm install && pnpm add react@canary react-dom@canary && pnpm build", + "test:assert": "pnpm -v" }, "eslintConfig": { "extends": [ diff --git a/packages/e2e-tests/test-applications/create-react-app/test-recipe.json b/packages/e2e-tests/test-applications/create-react-app/test-recipe.json deleted file mode 100644 index f0f5e19553cc..000000000000 --- a/packages/e2e-tests/test-applications/create-react-app/test-recipe.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "create-react-app", - "buildCommand": "pnpm install && pnpm build", - "tests": [], - "versions": [ - { - "dependencyOverrides": { - "typescript": "3.8.3" - } - } - ], - "canaryVersions": [ - { - "dependencyOverrides": { - "react": "canary", - "react-dom": "canary" - } - } - ] -} diff --git a/packages/e2e-tests/test-applications/create-remix-app/app/entry.client.tsx b/packages/e2e-tests/test-applications/create-remix-app/app/entry.client.tsx index edb18224d6c6..a4d1618fd976 100644 --- a/packages/e2e-tests/test-applications/create-remix-app/app/entry.client.tsx +++ b/packages/e2e-tests/test-applications/create-remix-app/app/entry.client.tsx @@ -10,7 +10,7 @@ import { hydrateRoot } from 'react-dom/client'; import * as Sentry from '@sentry/remix'; Sentry.init({ - dsn: process.env.REMIX_APP_E2E_TEST_DSN, + dsn: process.env.E2E_TEST_DSN, integrations: [ new Sentry.BrowserTracing({ routingInstrumentation: Sentry.remixRouterInstrumentation(useEffect, useLocation, useMatches), diff --git a/packages/e2e-tests/test-applications/create-remix-app/app/entry.server.tsx b/packages/e2e-tests/test-applications/create-remix-app/app/entry.server.tsx index c9975e940e21..62dd7ea43df2 100644 --- a/packages/e2e-tests/test-applications/create-remix-app/app/entry.server.tsx +++ b/packages/e2e-tests/test-applications/create-remix-app/app/entry.server.tsx @@ -16,7 +16,7 @@ import * as Sentry from '@sentry/remix'; const ABORT_DELAY = 5_000; Sentry.init({ - dsn: process.env.REMIX_APP_E2E_TEST_DSN, + dsn: process.env.E2E_TEST_DSN, // Performance Monitoring tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production! }); diff --git a/packages/e2e-tests/test-applications/create-remix-app/package.json b/packages/e2e-tests/test-applications/create-remix-app/package.json index ce7b8cd8456c..3a8bac491136 100644 --- a/packages/e2e-tests/test-applications/create-remix-app/package.json +++ b/packages/e2e-tests/test-applications/create-remix-app/package.json @@ -5,7 +5,9 @@ "build": "remix build", "dev": "remix dev", "start": "remix-serve build", - "typecheck": "tsc" + "typecheck": "tsc", + "test:build": "pnpm install && pnpm build", + "test:assert": "pnpm -v" }, "dependencies": { "@sentry/remix": "latest || *", diff --git a/packages/e2e-tests/test-applications/create-remix-app/test-recipe.json b/packages/e2e-tests/test-applications/create-remix-app/test-recipe.json deleted file mode 100644 index dc16b21af54c..000000000000 --- a/packages/e2e-tests/test-applications/create-remix-app/test-recipe.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "create-remix-app", - "buildCommand": "pnpm install && pnpm build", - "tests": [] -} diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts index cb7adf38cde8..7476b17c91da 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/assert-build.ts @@ -1,16 +1,16 @@ import * as fs from 'fs'; import * as assert from 'assert/strict'; -const stdin = fs.readFileSync(0).toString(); +const buildOutput = fs.readFileSync('.tmp_build_output', 'utf-8'); -// Assert that all static components stay static and ally dynamic components stay dynamic +// Assert that all static components stay static and all dynamic components stay dynamic -assert.match(stdin, /○ \/client-component/); -assert.match(stdin, /● \/client-component\/parameter\/\[\.\.\.parameters\]/); -assert.match(stdin, /● \/client-component\/parameter\/\[parameter\]/); +assert.match(buildOutput, /○ \/client-component/); +assert.match(buildOutput, /● \/client-component\/parameter\/\[\.\.\.parameters\]/); +assert.match(buildOutput, /● \/client-component\/parameter\/\[parameter\]/); -assert.match(stdin, /λ \/server-component/); -assert.match(stdin, /λ \/server-component\/parameter\/\[\.\.\.parameters\]/); -assert.match(stdin, /λ \/server-component\/parameter\/\[parameter\]/); +assert.match(buildOutput, /λ \/server-component/); +assert.match(buildOutput, /λ \/server-component\/parameter\/\[\.\.\.parameters\]/); +assert.match(buildOutput, /λ \/server-component\/parameter\/\[parameter\]/); export {}; diff --git a/packages/e2e-tests/test-utils/event-proxy-server.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/event-proxy-server.ts similarity index 100% rename from packages/e2e-tests/test-utils/event-proxy-server.ts rename to packages/e2e-tests/test-applications/nextjs-app-dir/event-proxy-server.ts diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/package.json b/packages/e2e-tests/test-applications/nextjs-app-dir/package.json index 58e4ac82b793..a5ce5514e3ca 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/package.json +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/package.json @@ -3,9 +3,14 @@ "version": "0.1.0", "private": true, "scripts": { - "build": "next build", + "build": "next build > .tmp_build_output", "test:prod": "TEST_ENV=production playwright test", - "test:dev": "TEST_ENV=development playwright test" + "test:dev": "TEST_ENV=development playwright test", + "test:build": "pnpm install && npx playwright install && pnpm build", + "test:test-build": "pnpm ts-node --script-mode assert-build.ts", + "test:build-canary": "pnpm install && pnpm add next@canary && npx playwright install && pnpm build", + "test:build-latest": "pnpm install && pnpm add next@latest && npx playwright install && pnpm build", + "test:assert": "pnpm test:test-build && pnpm test:prod && pnpm test:dev" }, "dependencies": { "@next/font": "13.0.7", @@ -21,6 +26,10 @@ "ts-node": "10.9.1", "@playwright/test": "^1.27.1" }, + "devDependencies": { + "@sentry/types": "latest || *", + "@sentry/utils": "latest || *" + }, "volta": { "node": "16.19.0", "yarn": "1.22.19" diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/playwright.config.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/playwright.config.ts index d151f812ee38..c0c413c0627b 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/playwright.config.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/playwright.config.ts @@ -7,8 +7,8 @@ if (!testEnv) { throw new Error('No test env defined'); } -const nextPort = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO); -const eventProxyPort = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP); +const nextPort = 3030; +const eventProxyPort = 3031; /** * See https://playwright.dev/docs/test-configuration. diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.client.config.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.client.config.ts index 11c76e31b460..ad780407a5b7 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.client.config.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.client.config.ts @@ -3,10 +3,6 @@ import * as Sentry from '@sentry/nextjs'; Sentry.init({ environment: 'qa', // dynamic sampling bias to keep transactions dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN, - tunnel: `http://localhost:${ - Number(process.env.NEXT_PUBLIC_BASE_PORT) + - Number(process.env.NEXT_PUBLIC_PORT_MODULO) + - Number(process.env.NEXT_PUBLIC_PORT_GAP) - }/`, // proxy server + tunnel: `http://localhost:3031/`, // proxy server tracesSampleRate: 1.0, }); diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.edge.config.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.edge.config.ts index 11c76e31b460..ad780407a5b7 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.edge.config.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.edge.config.ts @@ -3,10 +3,6 @@ import * as Sentry from '@sentry/nextjs'; Sentry.init({ environment: 'qa', // dynamic sampling bias to keep transactions dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN, - tunnel: `http://localhost:${ - Number(process.env.NEXT_PUBLIC_BASE_PORT) + - Number(process.env.NEXT_PUBLIC_PORT_MODULO) + - Number(process.env.NEXT_PUBLIC_PORT_GAP) - }/`, // proxy server + tunnel: `http://localhost:3031/`, // proxy server tracesSampleRate: 1.0, }); diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.server.config.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.server.config.ts index 11c76e31b460..ad780407a5b7 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.server.config.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/sentry.server.config.ts @@ -3,10 +3,6 @@ import * as Sentry from '@sentry/nextjs'; Sentry.init({ environment: 'qa', // dynamic sampling bias to keep transactions dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN, - tunnel: `http://localhost:${ - Number(process.env.NEXT_PUBLIC_BASE_PORT) + - Number(process.env.NEXT_PUBLIC_PORT_MODULO) + - Number(process.env.NEXT_PUBLIC_PORT_GAP) - }/`, // proxy server + tunnel: `http://localhost:3031/`, // proxy server tracesSampleRate: 1.0, }); diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/start-event-proxy.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/start-event-proxy.ts index 705af6e98a7a..ef8d204c5224 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/start-event-proxy.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/start-event-proxy.ts @@ -1,6 +1,6 @@ -import { startEventProxyServer } from '../../test-utils/event-proxy-server'; +import { startEventProxyServer } from './event-proxy-server'; startEventProxyServer({ - port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP), + port: 3031, proxyServerName: 'nextjs-13-app-dir', }); diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/test-recipe.json b/packages/e2e-tests/test-applications/nextjs-app-dir/test-recipe.json deleted file mode 100644 index 134eecd517e1..000000000000 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/test-recipe.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "nextjs-13-app-dir", - "buildCommand": "pnpm install && npx playwright install && pnpm build", - "buildAssertionCommand": "pnpm ts-node --script-mode assert-build.ts", - "tests": [ - { - "testName": "Prod Mode", - "testCommand": "pnpm test:prod" - }, - { - "testName": "Dev Mode", - "testCommand": "pnpm test:dev" - } - ], - "canaryVersions": [ - { - "dependencyOverrides": { - "next": "latest || *" - } - }, - { - "dependencyOverrides": { - "next": "canary" - } - } - ] -} diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/devErrorSymbolification.test.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/devErrorSymbolification.test.ts index f4841c2a6b16..03dd1b978714 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/devErrorSymbolification.test.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/devErrorSymbolification.test.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -import { waitForError } from '../../../test-utils/event-proxy-server'; +import { waitForError } from '../event-proxy-server'; test.describe('dev mode error symbolification', () => { if (process.env.TEST_ENV !== 'development') { diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/edge-route.test.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/edge-route.test.ts index 8f73764a919f..7d8d2a2fe97a 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/edge-route.test.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/edge-route.test.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -import { waitForTransaction, waitForError } from '../../../test-utils/event-proxy-server'; +import { waitForTransaction, waitForError } from '../event-proxy-server'; test('Should create a transaction for edge routes', async ({ request }) => { test.skip(process.env.TEST_ENV === 'development', "Doesn't work in dev mode."); diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/exceptions.test.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/exceptions.test.ts index ea96490b79ce..d31e869fd8b3 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/exceptions.test.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/exceptions.test.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -import { waitForError } from '../../../test-utils/event-proxy-server'; +import { waitForError } from '../event-proxy-server'; import axios, { AxiosError } from 'axios'; const authToken = process.env.E2E_TEST_AUTH_TOKEN; diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/middleware.test.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/middleware.test.ts index 268a55f1f481..95af8a7a8f29 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/middleware.test.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/middleware.test.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -import { waitForTransaction, waitForError } from '../../../test-utils/event-proxy-server'; +import { waitForTransaction, waitForError } from '../event-proxy-server'; test('Should create a transaction for middleware', async ({ request }) => { test.skip(process.env.TEST_ENV === 'development', "Doesn't work in dev mode."); diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/trace.test.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/trace.test.ts index 99d03266d01f..ed9a68513a19 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/trace.test.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/trace.test.ts @@ -1,5 +1,5 @@ import { test } from '@playwright/test'; -import { waitForTransaction } from '../../../test-utils/event-proxy-server'; +import { waitForTransaction } from '../event-proxy-server'; if (process.env.TEST_ENV === 'production') { // TODO: Fix that this is flakey on dev server - might be an SDK bug diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts index 8dac4e58e5ba..8413d623eb5c 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -import { waitForTransaction } from '../../../test-utils/event-proxy-server'; +import { waitForTransaction } from '../event-proxy-server'; import axios, { AxiosError } from 'axios'; const authToken = process.env.E2E_TEST_AUTH_TOKEN; diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/tsconfig.json b/packages/e2e-tests/test-applications/nextjs-app-dir/tsconfig.json index e78ff0d9c0e7..60825545944d 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/tsconfig.json +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/tsconfig.json @@ -17,7 +17,8 @@ { "name": "next" } - ] + ], + "incremental": true }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "next.config.js", ".next/types/**/*.ts"], "exclude": ["node_modules"], diff --git a/packages/e2e-tests/test-applications/node-express-app/package.json b/packages/e2e-tests/test-applications/node-express-app/package.json index ffd74762f286..45efd817e901 100644 --- a/packages/e2e-tests/test-applications/node-express-app/package.json +++ b/packages/e2e-tests/test-applications/node-express-app/package.json @@ -5,7 +5,9 @@ "scripts": { "build": "tsc", "start": "node dist/app.js", - "test": "playwright test" + "test": "playwright test", + "test:build": "pnpm install && pnpm build", + "test:assert": "pnpm test" }, "dependencies": { "@sentry/integrations": "latest || *", diff --git a/packages/e2e-tests/test-applications/node-express-app/playwright.config.ts b/packages/e2e-tests/test-applications/node-express-app/playwright.config.ts index d0544001644b..879d7b3d2093 100644 --- a/packages/e2e-tests/test-applications/node-express-app/playwright.config.ts +++ b/packages/e2e-tests/test-applications/node-express-app/playwright.config.ts @@ -58,7 +58,7 @@ const config: PlaywrightTestConfig = { /* Run your local dev server before starting the tests */ webServer: { command: 'pnpm start', - port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO), + port: 3030, }, }; diff --git a/packages/e2e-tests/test-applications/node-express-app/src/app.ts b/packages/e2e-tests/test-applications/node-express-app/src/app.ts index 1035a4958762..16aa82545b85 100644 --- a/packages/e2e-tests/test-applications/node-express-app/src/app.ts +++ b/packages/e2e-tests/test-applications/node-express-app/src/app.ts @@ -11,14 +11,14 @@ declare global { Sentry.init({ environment: 'qa', // dynamic sampling bias to keep transactions - dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN, + dsn: process.env.E2E_TEST_DSN, integrations: [new Integrations.HttpClient()], debug: true, tracesSampleRate: 1, }); const app = express(); -const port = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO); +const port = 3030; app.use(Sentry.Handlers.requestHandler()); app.use(Sentry.Handlers.tracingHandler()); diff --git a/packages/e2e-tests/test-applications/node-express-app/test-recipe.json b/packages/e2e-tests/test-applications/node-express-app/test-recipe.json deleted file mode 100644 index 08d5993e1c32..000000000000 --- a/packages/e2e-tests/test-applications/node-express-app/test-recipe.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "node-express-app", - "buildCommand": "pnpm install && pnpm build", - "tests": [ - { - "testName": "Test express server", - "testCommand": "pnpm test", - "timeoutSeconds": 60 - } - ] -} diff --git a/packages/e2e-tests/test-applications/react-create-hash-router/package.json b/packages/e2e-tests/test-applications/react-create-hash-router/package.json index fbd4f9017c50..c3bfaf4c9e0c 100644 --- a/packages/e2e-tests/test-applications/react-create-hash-router/package.json +++ b/packages/e2e-tests/test-applications/react-create-hash-router/package.json @@ -21,7 +21,10 @@ "scripts": { "build": "react-scripts build", "start": "serve -s build", - "test": "playwright test" + "test": "playwright test", + "test:build": "pnpm install && npx playwright install && pnpm build", + "test:build-canary": "pnpm install && pnpm add react@canary react-dom@canary && npx playwright install && pnpm build", + "test:assert": "pnpm test" }, "eslintConfig": { "extends": [ diff --git a/packages/e2e-tests/test-applications/react-create-hash-router/playwright.config.ts b/packages/e2e-tests/test-applications/react-create-hash-router/playwright.config.ts index a24d7bc1c742..c68482378d7a 100644 --- a/packages/e2e-tests/test-applications/react-create-hash-router/playwright.config.ts +++ b/packages/e2e-tests/test-applications/react-create-hash-router/playwright.config.ts @@ -60,9 +60,9 @@ const config: PlaywrightTestConfig = { /* Run your local dev server before starting the tests */ webServer: { command: 'pnpm start', - port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO), + port: 3030, env: { - PORT: String(Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO)), + PORT: '3030', }, }, }; diff --git a/packages/e2e-tests/test-applications/react-create-hash-router/src/index.tsx b/packages/e2e-tests/test-applications/react-create-hash-router/src/index.tsx index aef574bce3c4..643541357342 100644 --- a/packages/e2e-tests/test-applications/react-create-hash-router/src/index.tsx +++ b/packages/e2e-tests/test-applications/react-create-hash-router/src/index.tsx @@ -37,6 +37,8 @@ Sentry.init({ // Always capture replays, so we can test this properly replaysSessionSampleRate: 1.0, replaysOnErrorSampleRate: 0.0, + + debug: true, }); Object.defineProperty(window, 'sentryReplayId', { diff --git a/packages/e2e-tests/test-applications/react-create-hash-router/test-recipe.json b/packages/e2e-tests/test-applications/react-create-hash-router/test-recipe.json deleted file mode 100644 index 2fa5a9b823aa..000000000000 --- a/packages/e2e-tests/test-applications/react-create-hash-router/test-recipe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "react-create-hash-router", - "buildCommand": "pnpm install && npx playwright install && pnpm build", - "tests": [ - { - "testName": "Playwright tests", - "testCommand": "pnpm test" - } - ], - "canaryVersions": [ - { - "dependencyOverrides": { - "react": "latest || *", - "react-dom": "latest || *" - } - } - ] -} diff --git a/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/package.json b/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/package.json index f024d9426fb3..8ad3f32e13e9 100644 --- a/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/package.json +++ b/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/package.json @@ -22,7 +22,9 @@ "scripts": { "build": "react-scripts build", "start": "serve -s build", - "test": "playwright test" + "test": "playwright test", + "test:build": "pnpm install && npx playwright install && pnpm build", + "test:assert": "pnpm test" }, "eslintConfig": { "extends": [ diff --git a/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/playwright.config.ts b/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/playwright.config.ts index a24d7bc1c742..c68482378d7a 100644 --- a/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/playwright.config.ts +++ b/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/playwright.config.ts @@ -60,9 +60,9 @@ const config: PlaywrightTestConfig = { /* Run your local dev server before starting the tests */ webServer: { command: 'pnpm start', - port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO), + port: 3030, env: { - PORT: String(Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO)), + PORT: '3030', }, }, }; diff --git a/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/test-recipe.json b/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/test-recipe.json deleted file mode 100644 index 3f38669e0587..000000000000 --- a/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/test-recipe.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "standard-frontend-react-tracing-import", - "buildCommand": "pnpm install && npx playwright install && pnpm build", - "tests": [ - { - "testName": "Playwright tests", - "testCommand": "pnpm test" - } - ], - "canaryVersions": [] -} diff --git a/packages/e2e-tests/test-applications/standard-frontend-react/package.json b/packages/e2e-tests/test-applications/standard-frontend-react/package.json index 875fa3157b5a..554821b1366c 100644 --- a/packages/e2e-tests/test-applications/standard-frontend-react/package.json +++ b/packages/e2e-tests/test-applications/standard-frontend-react/package.json @@ -21,7 +21,11 @@ "scripts": { "build": "react-scripts build", "start": "serve -s build", - "test": "playwright test" + "test": "playwright test", + "test:build": "pnpm install && npx playwright install && pnpm build", + "test:build-ts3.8": "pnpm install && pnpm add typescript@3.8 && npx playwright install && pnpm build", + "test:build-canary": "pnpm install && pnpm add react@canary react-dom@canary && npx playwright install && pnpm build", + "test:assert": "pnpm test" }, "eslintConfig": { "extends": [ diff --git a/packages/e2e-tests/test-applications/standard-frontend-react/playwright.config.ts b/packages/e2e-tests/test-applications/standard-frontend-react/playwright.config.ts index a24d7bc1c742..c68482378d7a 100644 --- a/packages/e2e-tests/test-applications/standard-frontend-react/playwright.config.ts +++ b/packages/e2e-tests/test-applications/standard-frontend-react/playwright.config.ts @@ -60,9 +60,9 @@ const config: PlaywrightTestConfig = { /* Run your local dev server before starting the tests */ webServer: { command: 'pnpm start', - port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO), + port: 3030, env: { - PORT: String(Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO)), + PORT: '3030', }, }, }; diff --git a/packages/e2e-tests/test-applications/standard-frontend-react/test-recipe.json b/packages/e2e-tests/test-applications/standard-frontend-react/test-recipe.json deleted file mode 100644 index c0ac9c697a1d..000000000000 --- a/packages/e2e-tests/test-applications/standard-frontend-react/test-recipe.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "standard-frontend-react", - "buildCommand": "pnpm install && npx playwright install && pnpm build", - "tests": [ - { - "testName": "Playwright tests", - "testCommand": "pnpm test" - } - ], - "versions": [ - { - "dependencyOverrides": { - "typescript": "3.8.3" - } - } - ], - "canaryVersions": [ - { - "dependencyOverrides": { - "react": "latest || *", - "react-dom": "latest || *" - } - } - ] -} diff --git a/packages/e2e-tests/test-applications/sveltekit/event-proxy-server.ts b/packages/e2e-tests/test-applications/sveltekit/event-proxy-server.ts index 34d77e629e1e..c61e20d4081d 100644 --- a/packages/e2e-tests/test-applications/sveltekit/event-proxy-server.ts +++ b/packages/e2e-tests/test-applications/sveltekit/event-proxy-server.ts @@ -1,18 +1,3 @@ -// This is vendored from packages/e2e-tests/test-utils/event-proxy-server.ts -// This is done because otherwise we were getting `ERR_MODULE_NOT_FOUND`: -// -// CustomError: Cannot find module '/sentry-javascript/packages/e2e-tests/test-utils/event-proxy-server' imported from /sentry-javascript/packages/e2e-tests/test-applications/sveltekit/start-event-proxy.ts -// at finalizeResolution (/sentry-javascript/packages/e2e-tests/test-applications/sveltekit/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:366:11) -// at moduleResolve (/sentry-javascript/packages/e2e-tests/test-applications/sveltekit/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:801:10) -// at Object.defaultResolve (/sentry-javascript/packages/e2e-tests/test-applications/sveltekit/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:912:11) -// at /sentry-javascript/packages/e2e-tests/test-applications/sveltekit/node_modules/ts-node/src/esm.ts:218:35 -// at entrypointFallback (/sentry-javascript/packages/e2e-tests/test-applications/sveltekit/node_modules/ts-node/src/esm.ts:168:34) -// at /sentry-javascript/packages/e2e-tests/test-applications/sveltekit/node_modules/ts-node/src/esm.ts:217:14 -// at addShortCircuitFlag (/sentry-javascript/packages/e2e-tests/test-applications/sveltekit/node_modules/ts-node/src/esm.ts:409:21) -// at resolve (/sentry-javascript/packages/e2e-tests/test-applications/sveltekit/node_modules/ts-node/src/esm.ts:197:12) -// at resolve (/sentry-javascript/packages/e2e-tests/test-applications/sveltekit/node_modules/ts-node/src/child/child-loader.ts:15:39) -// at nextResolve (node:internal/modules/esm/loader:163:28) - import type { Envelope, EnvelopeItem, Event } from '@sentry/types'; import { parseEnvelope } from '@sentry/utils'; import * as fs from 'fs'; diff --git a/packages/e2e-tests/test-applications/sveltekit/package.json b/packages/e2e-tests/test-applications/sveltekit/package.json index 37fa0663edb7..4c644d83127a 100644 --- a/packages/e2e-tests/test-applications/sveltekit/package.json +++ b/packages/e2e-tests/test-applications/sveltekit/package.json @@ -9,13 +9,17 @@ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "test:prod": "TEST_ENV=production playwright test", - "test:dev": "TEST_ENV=development playwright test" + "test:dev": "TEST_ENV=development playwright test", + "test:build": "pnpm install && pnpm build", + "test:assert": "pnpm -v" }, "dependencies": { "@sentry/sveltekit": "latest || *" }, "devDependencies": { "@playwright/test": "^1.27.1", + "@sentry/types": "latest || *", + "@sentry/utils": "latest || *", "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-node": "^1.2.4", "@sveltejs/kit": "^1.5.0", diff --git a/packages/e2e-tests/test-applications/sveltekit/playwright.config.ts b/packages/e2e-tests/test-applications/sveltekit/playwright.config.ts index edeec487f24c..e38177e51a90 100644 --- a/packages/e2e-tests/test-applications/sveltekit/playwright.config.ts +++ b/packages/e2e-tests/test-applications/sveltekit/playwright.config.ts @@ -7,7 +7,7 @@ if (!testEnv) { throw new Error('No test env defined'); } -const port = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO); +const port = 3030; /** * See https://playwright.dev/docs/test-configuration. @@ -56,7 +56,7 @@ const config: PlaywrightTestConfig = { webServer: [ { command: 'pnpm ts-node --esm start-event-proxy.ts', - port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP), + port: 3031, }, { command: diff --git a/packages/e2e-tests/test-applications/sveltekit/src/hooks.client.ts b/packages/e2e-tests/test-applications/sveltekit/src/hooks.client.ts index 243813eda7b8..bfe90b150886 100644 --- a/packages/e2e-tests/test-applications/sveltekit/src/hooks.client.ts +++ b/packages/e2e-tests/test-applications/sveltekit/src/hooks.client.ts @@ -5,9 +5,7 @@ Sentry.init({ environment: 'qa', // dynamic sampling bias to keep transactions dsn: env.PUBLIC_E2E_TEST_DSN, debug: true, - tunnel: `http://localhost:${ - Number(env.PUBLIC_BASE_PORT) + Number(env.PUBLIC_PORT_MODULO) + Number(env.PUBLIC_PORT_GAP) - }/`, // proxy server + tunnel: `http://localhost:3031/`, // proxy server tracesSampleRate: 1.0, }); diff --git a/packages/e2e-tests/test-applications/sveltekit/src/hooks.server.ts b/packages/e2e-tests/test-applications/sveltekit/src/hooks.server.ts index f049ff9b48f0..2d9cb9b02328 100644 --- a/packages/e2e-tests/test-applications/sveltekit/src/hooks.server.ts +++ b/packages/e2e-tests/test-applications/sveltekit/src/hooks.server.ts @@ -5,7 +5,7 @@ Sentry.init({ environment: 'qa', // dynamic sampling bias to keep transactions dsn: env.E2E_TEST_DSN, debug: true, - tunnel: `http://localhost:${Number(env.BASE_PORT) + Number(env.PORT_MODULO) + Number(env.PORT_GAP)}/`, // proxy server + tunnel: `http://localhost:3031/`, // proxy server tracesSampleRate: 1.0, }); diff --git a/packages/e2e-tests/test-applications/sveltekit/start-event-proxy.ts b/packages/e2e-tests/test-applications/sveltekit/start-event-proxy.ts index cac3cea3bacd..db7640e0d825 100644 --- a/packages/e2e-tests/test-applications/sveltekit/start-event-proxy.ts +++ b/packages/e2e-tests/test-applications/sveltekit/start-event-proxy.ts @@ -1,6 +1,6 @@ import { startEventProxyServer } from './event-proxy-server'; startEventProxyServer({ - port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP), + port: 3031, proxyServerName: 'sveltekit', }); diff --git a/packages/e2e-tests/test-applications/sveltekit/test-recipe.json b/packages/e2e-tests/test-applications/sveltekit/test-recipe.json deleted file mode 100644 index 4060ceedd815..000000000000 --- a/packages/e2e-tests/test-applications/sveltekit/test-recipe.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "../../test-recipe-schema.json", - "testApplicationName": "Sveltekit", - "buildCommand": "pnpm install && pnpm build", - "tests": [] -} diff --git a/packages/e2e-tests/test-recipe-schema.json b/packages/e2e-tests/test-recipe-schema.json deleted file mode 100644 index ee14c2eb4f82..000000000000 --- a/packages/e2e-tests/test-recipe-schema.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Sentry JavaScript E2E Test Recipe", - "type": "object", - "properties": { - "testApplicationName": { - "type": "string", - "description": "Name displayed in test output" - }, - "buildCommand": { - "type": "string", - "description": "Command that is run to install dependencies and build the test application. This command is only run once before all tests. Working directory of the command is the root of the test application." - }, - "buildAssertionCommand": { - "type": "string", - "description": "Command to verify build output. This command will be run after the build is complete. The command will receive the STDOUT of the `buildCommand` as STDIN." - }, - "buildTimeoutSeconds": { - "type": "number", - "description": "Timeout for the build command in seconds. Default: 5 minutes" - }, - "testTimeoutSeconds": { - "type": "number", - "description": "Timeout for the test command in seconds. Default: 2 minutes" - }, - "tests": { - "type": "array", - "description": "Tests to run in this test application", - "items": { - "type": "object", - "properties": { - "testName": { - "type": "string", - "description": "Name displayed in test output" - }, - "testCommand": { - "type": "string", - "description": "Command that is run to start the test. Working directory of the command is the root of the test application. If this command returns a non-zero exit code the test counts as failed." - }, - "timeoutSeconds": { - "type": "number", - "description": "Test timeout in seconds. Default: 60" - } - }, - "required": ["testName", "testCommand"] - } - }, - "versions": { - "type": "array", - "description": "List of different dependency versions to test. If this property is provided, the tests will run for each item, if it is omitted, the tests will only run once with the dependencies provided in package.json.", - "items": { - "type": "object", - "properties": { - "dependencyOverrides": { - "type": "object", - "description": "Object to merge with the \"dependencies\" object in package.json.", - "additionalProperties": { "type": "string" } - } - } - } - }, - "canaryVersions": { - "type": "array", - "description": "List of different dependency versions to test as part of the canary test. Canary tests are only run if the CANARY_E2E_TEST environment variable is set. If If CANARY_E2E_TEST is set and this property is provided, the tests will run for each item, if it is omitted, no tests will be executed.", - "items": { - "type": "object", - "properties": { - "dependencyOverrides": { - "type": "object", - "description": "Object to merge with the \"dependencies\" object in package.json.", - "additionalProperties": { "type": "string" } - } - } - } - } - }, - "required": ["testApplicationName", "tests"] -} diff --git a/packages/sveltekit/src/server/index.ts b/packages/sveltekit/src/server/index.ts index 3475a3dbd894..3641993149bf 100644 --- a/packages/sveltekit/src/server/index.ts +++ b/packages/sveltekit/src/server/index.ts @@ -1,5 +1,5 @@ // Node SDK exports -// Unfortunately, we cannot `exprt * from '@sentry/node'` because in prod builds, +// Unfortunately, we cannot `export * from '@sentry/node'` because in prod builds, // Vite puts these exports into a `default` property (Sentry.default) rather than // on the top - level namespace. // Hence, we export everything from the Node SDK explicitly: diff --git a/yarn.lock b/yarn.lock index f188bedfcdf3..6619037a8e38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13698,15 +13698,6 @@ fs-constants@^1.0.0: resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== -fs-extra@11.1.0, fs-extra@^11.1.0: - version "11.1.0" - resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.0.tgz#5784b102104433bb0e090f48bfc4a30742c357ed" - integrity sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - fs-extra@4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.2.tgz#f91704c53d1b461f893452b0c307d9997647ab6b" @@ -13735,6 +13726,15 @@ fs-extra@^10.0.0, fs-extra@^10.1.0: jsonfile "^6.0.1" universalify "^2.0.0" +fs-extra@^11.1.0: + version "11.1.0" + resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.0.tgz#5784b102104433bb0e090f48bfc4a30742c357ed" + integrity sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-extra@^11.1.1: version "11.1.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.1.tgz#da69f7c39f3b002378b0954bb6ae7efdc0876e2d"