Skip to content

Commit

Permalink
chore(test): Disable Vitest globals
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Feb 26, 2025
1 parent 317782c commit 0f23911
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 13 deletions.
2 changes: 2 additions & 0 deletions packages/astro/test/server/index.server.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sentryAstro from '../../src/index.server';
import { describe, expect, it } from 'vitest';

describe('server SDK', () => {
it('exports the astro integration as a default export', () => {
const integration = sentryAstro();
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/server/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as SentryNode from '@sentry/node';
import { SDK_VERSION } from '@sentry/node';
import { vi } from 'vitest';
import { vi, describe, afterEach, expect, it } from 'vitest';

import { init } from '../../src/server/sdk';

Expand Down
1 change: 1 addition & 0 deletions packages/browser-utils/test/browser/browserMetrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { Span } from '@sentry/core';
import { _addMeasureSpans, _addResourceSpans } from '../../src/metrics/browserMetrics';
import { WINDOW } from '../../src/types';
import { TestClient, getDefaultClientOptions } from '../utils/TestClient';
import {describe, beforeEach, it, expect, beforeAll, afterAll } from 'vitest';

const mockWindowLocation = {
ancestorOrigins: {},
Expand Down
1 change: 1 addition & 0 deletions packages/browser-utils/test/browser/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SentrySpan, getCurrentScope, getIsolationScope, setCurrentClient, spanToJSON } from '@sentry/core';
import { extractNetworkProtocol, startAndEndSpan } from '../../src/metrics/utils';
import { TestClient, getDefaultClientOptions } from '../utils/TestClient';
import { describe, beforeEach, it, expect, test } from 'vitest';

describe('startAndEndSpan()', () => {
beforeEach(() => {
Expand Down
1 change: 1 addition & 0 deletions packages/browser-utils/test/instrument/dom.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { instrumentDOM } from '../../src/instrument/dom';
import { WINDOW } from '../../src/types';
import { describe, expect, it } from 'vitest';

// @ts-expect-error - idk
WINDOW.XMLHttpRequest = undefined;
Expand Down
1 change: 1 addition & 0 deletions packages/browser-utils/test/instrument/xhr.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { instrumentXHR } from '../../src/instrument/xhr';
import { WINDOW } from '../../src/types';
import { describe, expect, it } from 'vitest';

// @ts-expect-error - idk
WINDOW.XMLHttpRequest = undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/* eslint-disable @typescript-eslint/unbound-method */
import type { Mock } from 'vitest';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { afterEach, beforeEach, describe, expect, it, vi, afterAll, test } from 'vitest';

import * as SentryCore from '@sentry/core';
import { createTransport } from '@sentry/core';
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/test/tracing/request.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MockInstance } from 'vitest';
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { beforeAll, beforeEach, describe, expect, it, vi, afterEach } from 'vitest';

import * as browserUtils from '@sentry-internal/browser-utils';
import * as utils from '@sentry/core';
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/test/transports/offline.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it, beforeAll } from 'vitest';

import 'fake-indexeddb/auto';

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/test/utils/featureFlags.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FeatureFlag } from '@sentry/core';

import { getCurrentScope, logger } from '@sentry/core';
import { vi } from 'vitest';
import { vi, describe, it, afterEach, expect } from 'vitest';
import { insertFlagToScope, insertToFlagBuffer } from '../../src/utils/featureFlags';

describe('flags', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/utils-hoist/envelope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
spanToJSON,
} from '@sentry/core';
import { SentrySpan } from '@sentry/core';
import { describe, expect, it, test, vi } from 'vitest';
import { describe, expect, it, test, vi, afterEach } from 'vitest';
import { getSentryCarrier } from '../../src/carrier';
import {
addItemToEnvelope,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RuleTester } from 'eslint';
import { describe } from 'vitest';
import { describe, test } from 'vitest';

// @ts-expect-error untyped module
import rule from '../../../src/rules/no-eq-empty';
Expand Down
2 changes: 1 addition & 1 deletion packages/feedback/test/core/getFeedback.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { vi, describe, it, expect } from 'vitest';
import { vi, describe, it, expect, beforeEach } from 'vitest';

import { getCurrentScope } from '@sentry/core';
import { getFeedback } from '../../src/core/getFeedback';
Expand Down
2 changes: 1 addition & 1 deletion packages/feedback/test/core/sendFeedback.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @vitest-environment jsdom
*/
import { vi, describe, it, expect } from 'vitest';
import { vi, describe, it, expect, beforeEach, afterAll } from 'vitest';

import {
addBreadcrumb,
Expand Down
2 changes: 1 addition & 1 deletion packages/nestjs/test/integrations/nest.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { beforeEach, describe, expect, it, vi, afterEach } from 'vitest';

import * as core from '@sentry/core';
import { isPatched } from '../../src/integrations/helpers';
Expand Down
1 change: 1 addition & 0 deletions packages/react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import baseConfig from '../../vite/vite.config';
export default defineConfig({
...baseConfig,
test: {
globals: true,
...baseConfig.test,
},
});
2 changes: 1 addition & 1 deletion packages/replay-internal/test.setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { printDiffOrStringify } from 'jest-matcher-utils';
import { vi } from 'vitest';
import { vi, expect } from 'vitest';
import type { Mocked, MockedFunction } from 'vitest';

/* eslint-disable @typescript-eslint/no-unsafe-member-access */
Expand Down
2 changes: 1 addition & 1 deletion packages/replay-internal/test/unit/util/logger.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { beforeEach, describe, expect, it, vi } from 'vitest';

import * as SentryCore from '@sentry/core';
import { logger as coreLogger } from '@sentry/core';
Expand Down
1 change: 0 additions & 1 deletion vite/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default defineConfig({
__DEBUG_BUILD__: true,
},
test: {
globals: true,
coverage: {
enabled: true,
reportsDirectory: './coverage',
Expand Down

0 comments on commit 0f23911

Please sign in to comment.