Skip to content

Commit b2dded8

Browse files
authored
test(solid): Switch to explicit vitest imports (#13028)
As per https://vitest.dev/config/#globals > By default, vitest does not provide global APIs for explicitness I think we should follow vitest defaults here and explicitly import in the APIs that we need. This refactors our Solid SDK tests to do so. ref #11084 This change also removes `environment: 'jsdom'` from the vite config as it seems nothing needs this for solid. This should means that our tests are not polluted with jsdom globals, and that future writers have to explicitly opt-in to the behaviour.
1 parent 04a26a4 commit b2dded8

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

packages/solid/test/errorboundary.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* eslint-disable @typescript-eslint/unbound-method */
2+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3+
24
import type * as SentryBrowser from '@sentry/browser';
35
import { createTransport, getCurrentScope, setCurrentClient } from '@sentry/core';
46
import { render } from '@solidjs/testing-library';
57
import userEvent from '@testing-library/user-event';
6-
import { vi } from 'vitest';
78

89
import { ErrorBoundary } from 'solid-js';
910
import { BrowserClient, withSentryErrorBoundary } from '../src';

packages/solid/test/sdk.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { beforeEach, describe, expect, it, vi } from 'vitest';
2+
13
import { SDK_VERSION } from '@sentry/browser';
24
import * as SentryBrowser from '@sentry/browser';
35

4-
import { vi } from 'vitest';
56
import { init as solidInit } from '../src/sdk';
67

78
const browserInit = vi.spyOn(SentryBrowser, 'init');

packages/solid/test/solidrouter.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, expect, it, vi } from 'vitest';
2+
13
import { spanToJSON } from '@sentry/browser';
24
import {
35
SEMANTIC_ATTRIBUTE_SENTRY_OP,
@@ -10,7 +12,6 @@ import {
1012
import type { MemoryHistory } from '@solidjs/router';
1113
import { MemoryRouter, Navigate, Route, createMemoryHistory } from '@solidjs/router';
1214
import { render } from '@solidjs/testing-library';
13-
import { vi } from 'vitest';
1415

1516
import { BrowserClient } from '../src';
1617
import { solidRouterBrowserTracingIntegration, withSentryRouterRouting } from '../src/solidrouter';

packages/solid/tsconfig.test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
"compilerOptions": {
77
// should include all types from `./tsconfig.json` plus types for all test frameworks used
8-
"types": ["vitest/globals", "vite/client", "@testing-library/jest-dom"],
8+
"types": ["vite/client", "@testing-library/jest-dom"],
99

1010
// other package-specific, test-specific options
1111
"jsx": "preserve",

packages/solid/vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ export default {
66
plugins: [solidPlugin({ hot: !process.env.VITEST })],
77
test: {
88
...baseConfig.test,
9-
environment: 'jsdom',
109
},
1110
};

0 commit comments

Comments
 (0)