Skip to content

Commit 2d25f86

Browse files
committed
Remove the need for custom jest env
1 parent 2e85356 commit 2d25f86

File tree

6 files changed

+13
-23
lines changed

6 files changed

+13
-23
lines changed

packages/browser/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ const baseConfig = require('../../jest/jest.config.js');
22

33
module.exports = {
44
...baseConfig,
5-
testEnvironment: './jest.env.js',
5+
testEnvironment: 'jsdom',
66
testMatch: ['<rootDir>/test/unit/**/*.test.ts'],
77
};

packages/browser/jest.env.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/browser/test/unit/index.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe('SentryBrowser', () => {
4040
beforeSend,
4141
dsn,
4242
transport: makeSimpleTransport,
43+
autoSessionTracking: false,
4344
});
4445
});
4546

@@ -218,20 +219,20 @@ describe('SentryBrowser', () => {
218219
describe('SentryBrowser initialization', () => {
219220
it('should use window.SENTRY_RELEASE to set release on initialization if available', () => {
220221
global.SENTRY_RELEASE = { id: 'foobar' };
221-
init({ dsn });
222+
init({ dsn, autoSessionTracking: false });
222223
expect(global.__SENTRY__.hub._stack[0].client.getOptions().release).toBe('foobar');
223224
delete global.SENTRY_RELEASE;
224225
});
225226

226227
it('should use initialScope', () => {
227-
init({ dsn, initialScope: { tags: { a: 'b' } } });
228+
init({ dsn, initialScope: { tags: { a: 'b' } }, autoSessionTracking: false });
228229
expect(global.__SENTRY__.hub._stack[0].scope._tags).toEqual({ a: 'b' });
229230
});
230231

231232
it('should use initialScope Scope', () => {
232233
const scope = new Scope();
233234
scope.setTags({ a: 'b' });
234-
init({ dsn, initialScope: scope });
235+
init({ dsn, initialScope: scope, autoSessionTracking: false });
235236
expect(global.__SENTRY__.hub._stack[0].scope._tags).toEqual({ a: 'b' });
236237
});
237238

@@ -242,19 +243,20 @@ describe('SentryBrowser initialization', () => {
242243
scope.setTags({ a: 'b' });
243244
return scope;
244245
},
246+
autoSessionTracking: false,
245247
});
246248
expect(global.__SENTRY__.hub._stack[0].scope._tags).toEqual({ a: 'b' });
247249
});
248250

249251
it('should have initialization proceed as normal if window.SENTRY_RELEASE is not set', () => {
250252
// This is mostly a happy-path test to ensure that the initialization doesn't throw an error.
251-
init({ dsn });
253+
init({ dsn, autoSessionTracking: false });
252254
expect(global.__SENTRY__.hub._stack[0].client.getOptions().release).toBeUndefined();
253255
});
254256

255257
describe('SDK metadata', () => {
256258
it('should set SDK data when Sentry.init() is called', () => {
257-
init({ dsn });
259+
init({ dsn, autoSessionTracking: false });
258260

259261
const sdkData = (getCurrentHub().getClient() as any).getOptions()._metadata.sdk;
260262

@@ -265,7 +267,7 @@ describe('SentryBrowser initialization', () => {
265267
});
266268

267269
it('should set SDK data when instantiating a client directly', () => {
268-
const options = getDefaultBrowserClientOptions({ dsn });
270+
const options = getDefaultBrowserClientOptions({ dsn, autoSessionTracking: false });
269271
const client = new BrowserClient(options);
270272

271273
const sdkData = client.getOptions()._metadata?.sdk as any;
@@ -281,6 +283,7 @@ describe('SentryBrowser initialization', () => {
281283
it("shouldn't overwrite SDK data that's already there", () => {
282284
init({
283285
dsn,
286+
autoSessionTracking: false,
284287
// this would normally be set by the wrapper SDK in init()
285288
_metadata: {
286289
sdk: {

packages/browser/test/unit/transports/fetch.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { FetchImpl } from '../../../src/transports/utils';
88
const DEFAULT_FETCH_TRANSPORT_OPTIONS: FetchTransportOptions = {
99
url: 'https://sentry.io/api/42/store/?sentry_key=123&sentry_version=7',
1010
recordDroppedEvent: () => undefined,
11+
textEncoder: new TextEncoder(),
1112
};
1213

1314
const ERROR_ENVELOPE = createEnvelope<EventEnvelope>({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' }, [

packages/browser/test/unit/transports/xhr.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { makeXHRTransport, XHRTransportOptions } from '../../../src/transports/x
77
const DEFAULT_XHR_TRANSPORT_OPTIONS: XHRTransportOptions = {
88
url: 'https://sentry.io/api/42/store/?sentry_key=123&sentry_version=7',
99
recordDroppedEvent: () => undefined,
10+
textEncoder: new TextEncoder(),
1011
};
1112

1213
const ERROR_ENVELOPE = createEnvelope<EventEnvelope>({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' }, [

packages/gatsby/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ const baseConfig = require('../../jest/jest.config.js');
33
module.exports = {
44
...baseConfig,
55
setupFiles: ['<rootDir>/test/setEnvVars.ts'],
6-
testEnvironment: '../browser/jest.env.js',
6+
testEnvironment: 'jsdom',
77
};

0 commit comments

Comments
 (0)