Skip to content

test(browser): Remove getLocalTestPath in favor of getLocalTestUrl #14331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ${changedPaths.join('\n')}
* Returns how many time one test should run based on the chosen mode and a bunch of heuristics
*/
function getPerTestRunCount(testPaths: string[]) {
if (process.env.TEST_RUN_COUNT === 'AUTO' && testPaths.length > 0) {
if ((!process.env.TEST_RUN_COUNT || process.env.TEST_RUN_COUNT === 'AUTO') && testPaths.length > 0) {
// Run everything up to 100x, assuming that total runtime is less than 60min.
// We assume an average runtime of 3s per test, times 4 (for different browsers) = 12s per detected testPaths
// We want to keep overall runtime under 30min
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../uti

sentryTest(
'should add source context lines around stack frames from errors in Html inline JS',
async ({ getLocalTestPath, page, browserName }) => {
async ({ getLocalTestUrl, page, browserName }) => {
if (browserName === 'webkit') {
// The error we're throwing in this test is thrown as "Script error." in Webkit.
// We filter "Script error." out by default in `InboundFilters`.
Expand All @@ -15,9 +15,10 @@ sentryTest(
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });
const url = await getLocalTestUrl({ testDir: __dirname });

const eventReqPromise = waitForErrorRequestOnUrl(page, url);
await page.waitForFunction('window.Sentry');

const clickPromise = page.locator('#inline-error-btn').click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers';

sentryTest('should not add source context lines to errors from script files', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should not add source context lines to errors from script files', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventReqPromise = waitForErrorRequestOnUrl(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../uti

sentryTest(
'should add source context lines around stack frames from errors in Html script tags',
async ({ getLocalTestPath, page, browserName }) => {
async ({ getLocalTestUrl, page, browserName }) => {
if (browserName === 'webkit') {
// The error we're throwing in this test is thrown as "Script error." in Webkit.
// We filter "Script error." out by default in `InboundFilters`.
Expand All @@ -15,9 +15,10 @@ sentryTest(
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });
const url = await getLocalTestUrl({ testDir: __dirname });

const eventReqPromise = waitForErrorRequestOnUrl(page, url);
await page.waitForFunction('window.Sentry');

const clickPromise = page.locator('#inline-error-btn').click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest('should create errors with stack traces for failing fetch calls', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should create errors with stack traces for failing fetch calls', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const envelopes = await getMultipleSentryEnvelopeRequests<Event>(page, 3, { url, timeout: 10000 });
const errorEvent = envelopes.find(event => !event.type)!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers';

sentryTest('httpContextIntegration captures user-agent and referrer', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('httpContextIntegration captures user-agent and referrer', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const errorEventPromise = getFirstSentryEnvelopeRequest<Event>(page);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest(
'should assign request and response context from a failed 500 XHR request',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route('**/foo', route => {
return route.fulfill({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers';
// https://github.com/microsoft/playwright/issues/10376
sentryTest(
'should assign request and response context from a failed 500 fetch request',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route('**/foo', route => {
return route.fulfill({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import type { Event as SentryEvent } from '@sentry/types';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../../utils/helpers';

sentryTest('should handle aborted fetch calls', async ({ getLocalTestPath, page }) => {
sentryTest('should handle aborted fetch calls', async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route('**/foo', async () => {
// never fulfil this route because we abort the request as part of the test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers';

sentryTest('works with a Request passed in', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('works with a Request passed in', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route('**/foo', route => {
return route.fulfill({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers';

sentryTest(
'works with a Request (with body) & options passed in - handling used body',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route('**/foo', route => {
return route.fulfill({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers';

sentryTest('works with a Request (without body) & options passed in', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('works with a Request (without body) & options passed in', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route('**/foo', route => {
return route.fulfill({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest(
'should assign request and response context from a failed 500 XHR request',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

await page.route('**/foo', route => {
return route.fulfill({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should provide module_metadata on stack frames in beforeSend', async ({ getLocalTestPath, page }) => {
sentryTest('should provide module_metadata on stack frames in beforeSend', async ({ getLocalTestUrl, page }) => {
// moduleMetadataIntegration is not included in any CDN bundles
if (process.env.PW_BUNDLE?.startsWith('bundle')) {
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });
const url = await getLocalTestUrl({ testDir: __dirname });

const errorEvent = await getFirstSentryEnvelopeRequest<Event>(page, url);
expect(errorEvent.extra?.['module_metadata_entries']).toEqual([{ foo: 'bar' }]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest(
'should provide module_metadata on stack frames in beforeSend even though an event processor (rewriteFramesIntegration) modified the filename',
async ({ getLocalTestPath, page }) => {
async ({ getLocalTestUrl, page }) => {
// moduleMetadataIntegration is not included in any CDN bundles
if (process.env.PW_BUNDLE?.startsWith('bundle')) {
sentryTest.skip();
}

const url = await getLocalTestPath({ testDir: __dirname });
const url = await getLocalTestUrl({ testDir: __dirname });

const errorEvent = await getFirstSentryEnvelopeRequest<Event>(page, url);
expect(errorEvent?.extra?.['module_metadata_entries']).toEqual([{ foo: 'baz' }]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from '@playwright/test';
import { sentryTest } from '../../../utils/fixtures';
import { shouldSkipMetricsTest } from '../../../utils/helpers';

sentryTest('exports shim metrics integration for non-tracing bundles', async ({ getLocalTestPath, page }) => {
sentryTest('exports shim metrics integration for non-tracing bundles', async ({ getLocalTestUrl, page }) => {
// Skip in tracing tests
if (!shouldSkipMetricsTest()) {
sentryTest.skip();
Expand All @@ -22,7 +22,7 @@ sentryTest('exports shim metrics integration for non-tracing bundles', async ({
});
});

const url = await getLocalTestPath({ testDir: __dirname, skipDsnRouteHandler: true });
const url = await getLocalTestUrl({ testDir: __dirname, skipDsnRouteHandler: true });

await page.goto(url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest(
'should add an empty breadcrumb initialized with a timestamp, when an empty object is given',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should add multiple breadcrumbs', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should add multiple breadcrumbs', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should add a simple breadcrumb', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should add a simple breadcrumb', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest(
'should add an empty breadcrumb initialized with a timestamp, when no argument is given',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should capture an POJO', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should capture an POJO', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should capture an empty object', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should capture an empty object', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should capture an Event', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should capture an Event', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest(
'should capture recorded transactions as breadcrumbs for the following event sent',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const events = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should capture a linked error with messages', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should capture a linked error with messages', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest('should not reject back-to-back errors with different stack traces', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should not reject back-to-back errors with different stack traces', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getMultipleSentryEnvelopeRequests<Event>(page, 3, { url });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest('should reject duplicate, back-to-back errors from captureException', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should reject duplicate, back-to-back errors from captureException', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getMultipleSentryEnvelopeRequests<Event>(page, 7, { url });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should capture an class instance', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should capture an class instance', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest(
'should capture recorded transactions as breadcrumbs for the following event sent',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const events = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should capture an undefined error when no arguments are provided', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should capture an undefined error when no arguments are provided', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest(
'should reject duplicate, back-to-back messages from captureMessage when it has stacktrace',
async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getMultipleSentryEnvelopeRequests<Event>(page, 5, { url });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Event } from '@sentry/types';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers';

sentryTest('should capture a parameterized representation of the message', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
sentryTest('should capture a parameterized representation of the message', async ({ getLocalTestUrl, page }) => {
const url = await getLocalTestUrl({ testDir: __dirname });

const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

Expand Down
Loading
Loading