Skip to content

Commit b7eaf3e

Browse files
author
Luca Forstner
authored
test(e2e): Make E2E test org and project configurable via env variables (#6509)
1 parent 6e6e241 commit b7eaf3e

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,8 @@ jobs:
691691
E2E_TEST_PUBLISH_SCRIPT_NODE_VERSION: ${{ steps.versions.outputs.node }}
692692
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
693693
E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
694+
E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks'
695+
E2E_TEST_SENTRY_TEST_PROJECT: 'sentry-javascript-e2e-tests'
694696
run: |
695697
cd packages/e2e-tests
696698
yarn test:e2e

.github/workflows/canary.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
E2E_TEST_PUBLISH_SCRIPT_NODE_VERSION: ${{ steps.versions.outputs.node }}
4242
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
4343
E2E_TEST_DSN: ${{ secrets.E2E_TEST_DSN }}
44+
E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks'
45+
E2E_TEST_SENTRY_TEST_PROJECT: 'sentry-javascript-e2e-tests'
4446
CANARY_E2E_TEST: 'yes'
4547
run: |
4648
cd packages/e2e-tests

packages/e2e-tests/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
E2E_TEST_AUTH_TOKEN=
22
E2E_TEST_DSN=
3+
E2E_TEST_SENTRY_ORG_SLUG=
4+
E2E_TEST_SENTRY_TEST_PROJECT=

packages/e2e-tests/run.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,35 @@ const publishScriptNodeVersion = process.env.E2E_TEST_PUBLISH_SCRIPT_NODE_VERSIO
1717
const DEFAULT_BUILD_TIMEOUT_SECONDS = 60 * 5;
1818
const DEFAULT_TEST_TIMEOUT_SECONDS = 60 * 2;
1919

20+
let missingEnvVar = false;
21+
2022
if (!process.env.E2E_TEST_AUTH_TOKEN) {
2123
console.log(
2224
"No auth token configured! Please configure the E2E_TEST_AUTH_TOKEN environment variable with an auth token that has the scope 'project:read'!",
2325
);
26+
missingEnvVar = true;
2427
}
2528

2629
if (!process.env.E2E_TEST_DSN) {
2730
console.log('No DSN configured! Please configure the E2E_TEST_DSN environment variable with a DSN!');
31+
missingEnvVar = true;
32+
}
33+
34+
if (!process.env.E2E_TEST_SENTRY_ORG_SLUG) {
35+
console.log(
36+
'No Sentry organization slug configured! Please configure the E2E_TEST_SENTRY_ORG_SLUG environment variable with a Sentry organization slug!',
37+
);
38+
missingEnvVar = true;
39+
}
40+
41+
if (!process.env.E2E_TEST_SENTRY_TEST_PROJECT) {
42+
console.log(
43+
'No Sentry project configured! Please configure the E2E_TEST_SENTRY_TEST_PROJECT environment variable with a Sentry project slug!',
44+
);
45+
missingEnvVar = true;
2846
}
2947

30-
if (!process.env.E2E_TEST_AUTH_TOKEN || !process.env.E2E_TEST_DSN) {
48+
if (missingEnvVar) {
3149
process.exit(1);
3250
}
3351

packages/e2e-tests/test-applications/standard-frontend-react/tests/behaviour-test.spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { test, expect } from '@playwright/test';
22
import axios, { AxiosError } from 'axios';
33

4-
const SENTRY_TEST_ORG_SLUG = 'sentry-sdks';
5-
const SENTRY_TEST_PROJECT = 'sentry-javascript-e2e-tests';
6-
74
const EVENT_POLLING_TIMEOUT = 30_000;
85

96
const authToken = process.env.E2E_TEST_AUTH_TOKEN;
7+
const sentryTestOrgSlug = process.env.E2E_TEST_SENTRY_ORG_SLUG;
8+
const sentryTestProject = process.env.E2E_TEST_SENTRY_TEST_PROJECT;
109

1110
test('Sends an exception to Sentry', async ({ page }) => {
1211
await page.goto('/');
@@ -24,7 +23,7 @@ test('Sends an exception to Sentry', async ({ page }) => {
2423
async () => {
2524
try {
2625
const response = await axios.get(
27-
`https://sentry.io/api/0/projects/${SENTRY_TEST_ORG_SLUG}/${SENTRY_TEST_PROJECT}/events/${exceptionEventId}/`,
26+
`https://sentry.io/api/0/projects/${sentryTestOrgSlug}/${sentryTestProject}/events/${exceptionEventId}/`,
2827
{ headers: { Authorization: `Bearer ${authToken}` } },
2928
);
3029
return response.status;
@@ -74,7 +73,7 @@ test('Sends a pageload transaction to Sentry', async ({ page }) => {
7473
async () => {
7574
try {
7675
const response = await axios.get(
77-
`https://sentry.io/api/0/projects/${SENTRY_TEST_ORG_SLUG}/${SENTRY_TEST_PROJECT}/events/${transactionEventId}/`,
76+
`https://sentry.io/api/0/projects/${sentryTestOrgSlug}/${sentryTestProject}/events/${transactionEventId}/`,
7877
{ headers: { Authorization: `Bearer ${authToken}` } },
7978
);
8079

@@ -139,7 +138,7 @@ test('Sends a navigation transaction to Sentry', async ({ page }) => {
139138
async () => {
140139
try {
141140
const response = await axios.get(
142-
`https://sentry.io/api/0/projects/${SENTRY_TEST_ORG_SLUG}/${SENTRY_TEST_PROJECT}/events/${transactionEventId}/`,
141+
`https://sentry.io/api/0/projects/${sentryTestOrgSlug}/${sentryTestProject}/events/${transactionEventId}/`,
143142
{ headers: { Authorization: `Bearer ${authToken}` } },
144143
);
145144

0 commit comments

Comments
 (0)