Skip to content
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ module.exports = {
},
},
{
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['tsconfig.dev.json'],
},
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@ scratch/
# side effects of running AWS lambda layer zip action locally
dist-serverless/
sentry-node-serverless-*.zip
# transpiled transformers
jest/transformers/*.js
# node tarballs
packages/*/sentry-*.tgz
.nxcache
Expand Down
29 changes: 0 additions & 29 deletions .vscode/launch.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,35 +52,6 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
{
"name": "Debug unit tests - just open file",
"type": "node",
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--watch",
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
// you're hitting a single test's breakpoints, in order)
"--runInBand",
// coverage messes up the source maps
"--coverage",
"false",
// remove this to run all package tests
"${relativeFile}"
],
"sourceMaps": true,
"smartStep": true,
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
// "outputCapture" option here; default is to show console logs), but not both
"console": "integratedTerminal",
// since we're not using it, don't automatically switch to it
"internalConsoleOptions": "neverOpen"
},

// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
Expand Down
17 changes: 0 additions & 17 deletions CONTRIBUTING.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `

Note: you must run `yarn build` before `yarn test` will work.

## Debugging Tests

If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.

0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
tab in the sidebar as one of the recommended workspace extensions.

1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
4. Click the green "play" button to run the tests in the open file in watch mode.

Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
part of the buggy test.

## Debug Build Flags

Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/.eslintrc.js
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
module.exports = {
env: {
node: true,
jest: true,
},
extends: ['../../.eslintrc.js'],
overrides: [
Expand Down
6 changes: 2 additions & 4 deletions dev-packages/node-integration-tests/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ folders containing test scenarios and assertions.
`runServer` also accepts an optional `scenarioPath` argument for non-standard usage.

`test.ts` is required for each test case, and contains the server runner logic, request interceptors for Sentry
requests, and assertions. Test server, interceptors and assertions are all run on the same Jest thread.
requests, and assertions. Test server, interceptors and assertions are all run on the same Vitest thread.

### Utilities

Expand All@@ -40,12 +40,10 @@ Tests can be run locally with:

`yarn test`

To run tests with Jest's watch mode:
To run tests with Vitest's watch mode:

`yarn test:watch`

To filter tests by their title:

`yarn test -t "set different properties of a scope"`

You can refer to [Jest documentation](https://jestjs.io/docs/cli) for other CLI options.
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/tsconfig.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,6 @@
"lib": ["DOM", "ES2018"],
// package-specific options
"esModuleInterop": true,
"types": ["node", "jest"]
"types": ["node"]
}
}
43 changes: 0 additions & 43 deletions jest/jest.config.js

This file was deleted.

7 changes: 1 addition & 6 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"circularDepCheck": "lerna run circularDepCheck",
"clean": "run-s clean:build clean:caches",
"clean:build": "lerna run clean",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx",
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
"clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz",
"clean:watchman": "watchman watch-del \".\"",
Expand DownExpand Up@@ -110,17 +110,13 @@
"@rollup/pluginutils": "^5.1.0",
"@size-limit/file": "~11.1.6",
"@size-limit/webpack": "~11.1.6",
"@types/jest": "^27.4.1",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.1",
"@vitest/coverage-v8": "^2.1.8",
"deepmerge": "^4.2.2",
"downlevel-dts": "~0.11.0",
"es-check": "^7.2.1",
"eslint": "7.32.0",
"jest": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-junit": "^16.0.0",
"jsdom": "^21.1.2",
"lerna": "7.1.1",
"madge": "7.0.0",
Expand All@@ -133,7 +129,6 @@
"rollup-plugin-license": "^3.3.1",
"size-limit": "~11.1.6",
"sucrase": "^3.35.0",
"ts-jest": "^27.1.4",
"ts-node": "10.9.1",
"typescript": "~5.0.0",
"vitest": "^2.1.8",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -291,8 +291,6 @@ describe('checkOrSetAlreadyCaught()', () => {

describe('uuid4 generation', () => {
const uuid4Regex = /^[0-9A-F]{12}[4][0-9A-F]{3}[89AB][0-9A-F]{15}$/i;
// Jest messes with the global object, so there is no global crypto object in any node version
// For this reason we need to create our own crypto object for each test to cover all the code paths
it('returns valid uuid v4 ids via Math.random', () => {
for (let index = 0; index < 1_000; index++) {
expect(uuid4()).toMatch(uuid4Regex);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/utils-hoist/normalize.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import { describe, expect, test, vi } from 'vitest';
Expand Down
11 changes: 2 additions & 9 deletions packages/core/test/utils-hoist/object.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import type { WrappedFunction } from '../../src/types-hoist';
Expand DownExpand Up@@ -331,17 +331,10 @@ describe('objectify()', () => {
});

describe('wraps other primitives with their respective object wrapper classes', () => {
// TODO: There's currently a bug in Jest - if you give it the `Boolean` class, it runs `typeof received ===
// 'boolean'` but not `received instanceof Boolean` (the way it correctly does for other primitive wrappers, like
// `Number` and `String). (See https://github.com/facebook/jest/pull/11976.) Once that is fixed and we upgrade jest,
// we can comment the test below back in. (The tests for symbols and bigints are working only because our current
// version of jest is sufficiently old that they're not even considered in the relevant check and just fall to the
// default `instanceof` check jest uses for all unknown classes.)

it.each([
['number', Number, 1121],
['string', String, 'Dogs are great!'],
// ["boolean", Boolean, true],
['boolean', Boolean, true],
['symbol', Symbol, Symbol('Maisey')],
])('%s', (_caseName, wrapperClass, primitive) => {
const objectifiedPrimitive = objectify(primitive);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-sdk/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-simple-import-sort": "^5.0.3"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-config-sdk/src/base.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,10 +154,6 @@ module.exports = {
},
},
{
// Configuration for files in test directories
env: {
jest: true,
},
files: [
'test.ts',
'*.test.ts',
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/tsconfig.plugin.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
// "types": ["node", "jest"]
"declaration": true,
"declarationMap": false,
"emitDeclarationOnly": true,
Expand Down
1 change: 0 additions & 1 deletion packages/node/jest.config.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/node/test/helpers/conditional.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ const NODE_VERSION = parseSemver(process.versions.node).major;
* Returns`describe` or `describe.skip` depending on allowed major versions of Node.
*
* @param {{ min?: number; max?: number }} allowedVersion
* @return {*} {jest.Describe}
*/
export const conditionalTest = (allowedVersion: { min?: number; max?: number }) => {
if (!NODE_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/react-router/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
"types": ["node", "vitest/globals"],
"types": ["node"],
}
}
2 changes: 1 addition & 1 deletion packages/remix/test/integration/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*"],

"compilerOptions": {
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/solidstart/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

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

// other package-specific, test-specific options
"jsx": "preserve",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig-templates/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["jest"]
"types": []

// other package-specific, test-specific options
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.dev.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
{
"extends": "./tsconfig.json",

"include": ["**/scripts/**/*.ts", "jest/**/*.ts", "vite/**/*.ts"],
"include": ["**/scripts/**/*.ts", "vite/**/*.ts"],

"compilerOptions": {
"types": ["node", "jest", "vitest/globals"]
"types": ["node"]
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
chore(jest): Final Jest cleanup by timfish · Pull Request #15549 · getsentry/sentry-javascript · GitHub
Skip to content
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ module.exports = {
},
},
{
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['tsconfig.dev.json'],
},
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@ scratch/
# side effects of running AWS lambda layer zip action locally
dist-serverless/
sentry-node-serverless-*.zip
# transpiled transformers
jest/transformers/*.js
# node tarballs
packages/*/sentry-*.tgz
.nxcache
Expand Down
29 changes: 0 additions & 29 deletions .vscode/launch.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,35 +52,6 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
{
"name": "Debug unit tests - just open file",
"type": "node",
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--watch",
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
// you're hitting a single test's breakpoints, in order)
"--runInBand",
// coverage messes up the source maps
"--coverage",
"false",
// remove this to run all package tests
"${relativeFile}"
],
"sourceMaps": true,
"smartStep": true,
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
// "outputCapture" option here; default is to show console logs), but not both
"console": "integratedTerminal",
// since we're not using it, don't automatically switch to it
"internalConsoleOptions": "neverOpen"
},

// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
Expand Down
17 changes: 0 additions & 17 deletions CONTRIBUTING.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `

Note: you must run `yarn build` before `yarn test` will work.

## Debugging Tests

If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.

0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
tab in the sidebar as one of the recommended workspace extensions.

1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
4. Click the green "play" button to run the tests in the open file in watch mode.

Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
part of the buggy test.

## Debug Build Flags

Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/.eslintrc.js
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
module.exports = {
env: {
node: true,
jest: true,
},
extends: ['../../.eslintrc.js'],
overrides: [
Expand Down
6 changes: 2 additions & 4 deletions dev-packages/node-integration-tests/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ folders containing test scenarios and assertions.
`runServer` also accepts an optional `scenarioPath` argument for non-standard usage.

`test.ts` is required for each test case, and contains the server runner logic, request interceptors for Sentry
requests, and assertions. Test server, interceptors and assertions are all run on the same Jest thread.
requests, and assertions. Test server, interceptors and assertions are all run on the same Vitest thread.

### Utilities

Expand All@@ -40,12 +40,10 @@ Tests can be run locally with:

`yarn test`

To run tests with Jest's watch mode:
To run tests with Vitest's watch mode:

`yarn test:watch`

To filter tests by their title:

`yarn test -t "set different properties of a scope"`

You can refer to [Jest documentation](https://jestjs.io/docs/cli) for other CLI options.
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/tsconfig.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,6 @@
"lib": ["DOM", "ES2018"],
// package-specific options
"esModuleInterop": true,
"types": ["node", "jest"]
"types": ["node"]
}
}
43 changes: 0 additions & 43 deletions jest/jest.config.js

This file was deleted.

7 changes: 1 addition & 6 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"circularDepCheck": "lerna run circularDepCheck",
"clean": "run-s clean:build clean:caches",
"clean:build": "lerna run clean",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx",
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
"clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz",
"clean:watchman": "watchman watch-del \".\"",
Expand DownExpand Up@@ -110,17 +110,13 @@
"@rollup/pluginutils": "^5.1.0",
"@size-limit/file": "~11.1.6",
"@size-limit/webpack": "~11.1.6",
"@types/jest": "^27.4.1",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.1",
"@vitest/coverage-v8": "^2.1.8",
"deepmerge": "^4.2.2",
"downlevel-dts": "~0.11.0",
"es-check": "^7.2.1",
"eslint": "7.32.0",
"jest": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-junit": "^16.0.0",
"jsdom": "^21.1.2",
"lerna": "7.1.1",
"madge": "7.0.0",
Expand All@@ -133,7 +129,6 @@
"rollup-plugin-license": "^3.3.1",
"size-limit": "~11.1.6",
"sucrase": "^3.35.0",
"ts-jest": "^27.1.4",
"ts-node": "10.9.1",
"typescript": "~5.0.0",
"vitest": "^2.1.8",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -291,8 +291,6 @@ describe('checkOrSetAlreadyCaught()', () => {

describe('uuid4 generation', () => {
const uuid4Regex = /^[0-9A-F]{12}[4][0-9A-F]{3}[89AB][0-9A-F]{15}$/i;
// Jest messes with the global object, so there is no global crypto object in any node version
// For this reason we need to create our own crypto object for each test to cover all the code paths
it('returns valid uuid v4 ids via Math.random', () => {
for (let index = 0; index < 1_000; index++) {
expect(uuid4()).toMatch(uuid4Regex);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/utils-hoist/normalize.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import { describe, expect, test, vi } from 'vitest';
Expand Down
11 changes: 2 additions & 9 deletions packages/core/test/utils-hoist/object.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import type { WrappedFunction } from '../../src/types-hoist';
Expand DownExpand Up@@ -331,17 +331,10 @@ describe('objectify()', () => {
});

describe('wraps other primitives with their respective object wrapper classes', () => {
// TODO: There's currently a bug in Jest - if you give it the `Boolean` class, it runs `typeof received ===
// 'boolean'` but not `received instanceof Boolean` (the way it correctly does for other primitive wrappers, like
// `Number` and `String). (See https://github.com/facebook/jest/pull/11976.) Once that is fixed and we upgrade jest,
// we can comment the test below back in. (The tests for symbols and bigints are working only because our current
// version of jest is sufficiently old that they're not even considered in the relevant check and just fall to the
// default `instanceof` check jest uses for all unknown classes.)

it.each([
['number', Number, 1121],
['string', String, 'Dogs are great!'],
// ["boolean", Boolean, true],
['boolean', Boolean, true],
['symbol', Symbol, Symbol('Maisey')],
])('%s', (_caseName, wrapperClass, primitive) => {
const objectifiedPrimitive = objectify(primitive);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-sdk/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-simple-import-sort": "^5.0.3"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-config-sdk/src/base.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,10 +154,6 @@ module.exports = {
},
},
{
// Configuration for files in test directories
env: {
jest: true,
},
files: [
'test.ts',
'*.test.ts',
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/tsconfig.plugin.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
// "types": ["node", "jest"]
"declaration": true,
"declarationMap": false,
"emitDeclarationOnly": true,
Expand Down
1 change: 0 additions & 1 deletion packages/node/jest.config.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/node/test/helpers/conditional.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ const NODE_VERSION = parseSemver(process.versions.node).major;
* Returns`describe` or `describe.skip` depending on allowed major versions of Node.
*
* @param {{ min?: number; max?: number }} allowedVersion
* @return {*} {jest.Describe}
*/
export const conditionalTest = (allowedVersion: { min?: number; max?: number }) => {
if (!NODE_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/react-router/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
"types": ["node", "vitest/globals"],
"types": ["node"],
}
}
2 changes: 1 addition & 1 deletion packages/remix/test/integration/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*"],

"compilerOptions": {
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/solidstart/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

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

// other package-specific, test-specific options
"jsx": "preserve",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig-templates/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["jest"]
"types": []

// other package-specific, test-specific options
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.dev.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
{
"extends": "./tsconfig.json",

"include": ["**/scripts/**/*.ts", "jest/**/*.ts", "vite/**/*.ts"],
"include": ["**/scripts/**/*.ts", "vite/**/*.ts"],

"compilerOptions": {
"types": ["node", "jest", "vitest/globals"]
"types": ["node"]
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(jest): Final Jest cleanup by timfish · Pull Request #15549 · getsentry/sentry-javascript · GitHub
Skip to content
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ module.exports = {
},
},
{
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['tsconfig.dev.json'],
},
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@ scratch/
# side effects of running AWS lambda layer zip action locally
dist-serverless/
sentry-node-serverless-*.zip
# transpiled transformers
jest/transformers/*.js
# node tarballs
packages/*/sentry-*.tgz
.nxcache
Expand Down
29 changes: 0 additions & 29 deletions .vscode/launch.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,35 +52,6 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
{
"name": "Debug unit tests - just open file",
"type": "node",
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--watch",
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
// you're hitting a single test's breakpoints, in order)
"--runInBand",
// coverage messes up the source maps
"--coverage",
"false",
// remove this to run all package tests
"${relativeFile}"
],
"sourceMaps": true,
"smartStep": true,
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
// "outputCapture" option here; default is to show console logs), but not both
"console": "integratedTerminal",
// since we're not using it, don't automatically switch to it
"internalConsoleOptions": "neverOpen"
},

// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
Expand Down
17 changes: 0 additions & 17 deletions CONTRIBUTING.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `

Note: you must run `yarn build` before `yarn test` will work.

## Debugging Tests

If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.

0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
tab in the sidebar as one of the recommended workspace extensions.

1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
4. Click the green "play" button to run the tests in the open file in watch mode.

Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
part of the buggy test.

## Debug Build Flags

Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/.eslintrc.js
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
module.exports = {
env: {
node: true,
jest: true,
},
extends: ['../../.eslintrc.js'],
overrides: [
Expand Down
6 changes: 2 additions & 4 deletions dev-packages/node-integration-tests/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ folders containing test scenarios and assertions.
`runServer` also accepts an optional `scenarioPath` argument for non-standard usage.

`test.ts` is required for each test case, and contains the server runner logic, request interceptors for Sentry
requests, and assertions. Test server, interceptors and assertions are all run on the same Jest thread.
requests, and assertions. Test server, interceptors and assertions are all run on the same Vitest thread.

### Utilities

Expand All@@ -40,12 +40,10 @@ Tests can be run locally with:

`yarn test`

To run tests with Jest's watch mode:
To run tests with Vitest's watch mode:

`yarn test:watch`

To filter tests by their title:

`yarn test -t "set different properties of a scope"`

You can refer to [Jest documentation](https://jestjs.io/docs/cli) for other CLI options.
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/tsconfig.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,6 @@
"lib": ["DOM", "ES2018"],
// package-specific options
"esModuleInterop": true,
"types": ["node", "jest"]
"types": ["node"]
}
}
43 changes: 0 additions & 43 deletions jest/jest.config.js

This file was deleted.

7 changes: 1 addition & 6 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"circularDepCheck": "lerna run circularDepCheck",
"clean": "run-s clean:build clean:caches",
"clean:build": "lerna run clean",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx",
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
"clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz",
"clean:watchman": "watchman watch-del \".\"",
Expand DownExpand Up@@ -110,17 +110,13 @@
"@rollup/pluginutils": "^5.1.0",
"@size-limit/file": "~11.1.6",
"@size-limit/webpack": "~11.1.6",
"@types/jest": "^27.4.1",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.1",
"@vitest/coverage-v8": "^2.1.8",
"deepmerge": "^4.2.2",
"downlevel-dts": "~0.11.0",
"es-check": "^7.2.1",
"eslint": "7.32.0",
"jest": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-junit": "^16.0.0",
"jsdom": "^21.1.2",
"lerna": "7.1.1",
"madge": "7.0.0",
Expand All@@ -133,7 +129,6 @@
"rollup-plugin-license": "^3.3.1",
"size-limit": "~11.1.6",
"sucrase": "^3.35.0",
"ts-jest": "^27.1.4",
"ts-node": "10.9.1",
"typescript": "~5.0.0",
"vitest": "^2.1.8",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -291,8 +291,6 @@ describe('checkOrSetAlreadyCaught()', () => {

describe('uuid4 generation', () => {
const uuid4Regex = /^[0-9A-F]{12}[4][0-9A-F]{3}[89AB][0-9A-F]{15}$/i;
// Jest messes with the global object, so there is no global crypto object in any node version
// For this reason we need to create our own crypto object for each test to cover all the code paths
it('returns valid uuid v4 ids via Math.random', () => {
for (let index = 0; index < 1_000; index++) {
expect(uuid4()).toMatch(uuid4Regex);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/utils-hoist/normalize.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import { describe, expect, test, vi } from 'vitest';
Expand Down
11 changes: 2 additions & 9 deletions packages/core/test/utils-hoist/object.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import type { WrappedFunction } from '../../src/types-hoist';
Expand DownExpand Up@@ -331,17 +331,10 @@ describe('objectify()', () => {
});

describe('wraps other primitives with their respective object wrapper classes', () => {
// TODO: There's currently a bug in Jest - if you give it the `Boolean` class, it runs `typeof received ===
// 'boolean'` but not `received instanceof Boolean` (the way it correctly does for other primitive wrappers, like
// `Number` and `String). (See https://github.com/facebook/jest/pull/11976.) Once that is fixed and we upgrade jest,
// we can comment the test below back in. (The tests for symbols and bigints are working only because our current
// version of jest is sufficiently old that they're not even considered in the relevant check and just fall to the
// default `instanceof` check jest uses for all unknown classes.)

it.each([
['number', Number, 1121],
['string', String, 'Dogs are great!'],
// ["boolean", Boolean, true],
['boolean', Boolean, true],
['symbol', Symbol, Symbol('Maisey')],
])('%s', (_caseName, wrapperClass, primitive) => {
const objectifiedPrimitive = objectify(primitive);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-sdk/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-simple-import-sort": "^5.0.3"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-config-sdk/src/base.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,10 +154,6 @@ module.exports = {
},
},
{
// Configuration for files in test directories
env: {
jest: true,
},
files: [
'test.ts',
'*.test.ts',
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/tsconfig.plugin.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
// "types": ["node", "jest"]
"declaration": true,
"declarationMap": false,
"emitDeclarationOnly": true,
Expand Down
1 change: 0 additions & 1 deletion packages/node/jest.config.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/node/test/helpers/conditional.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ const NODE_VERSION = parseSemver(process.versions.node).major;
* Returns`describe` or `describe.skip` depending on allowed major versions of Node.
*
* @param {{ min?: number; max?: number }} allowedVersion
* @return {*} {jest.Describe}
*/
export const conditionalTest = (allowedVersion: { min?: number; max?: number }) => {
if (!NODE_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/react-router/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
"types": ["node", "vitest/globals"],
"types": ["node"],
}
}
2 changes: 1 addition & 1 deletion packages/remix/test/integration/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*"],

"compilerOptions": {
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/solidstart/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

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

// other package-specific, test-specific options
"jsx": "preserve",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig-templates/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["jest"]
"types": []

// other package-specific, test-specific options
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.dev.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
{
"extends": "./tsconfig.json",

"include": ["**/scripts/**/*.ts", "jest/**/*.ts", "vite/**/*.ts"],
"include": ["**/scripts/**/*.ts", "vite/**/*.ts"],

"compilerOptions": {
"types": ["node", "jest", "vitest/globals"]
"types": ["node"]
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(jest): Final Jest cleanup by timfish · Pull Request #15549 · getsentry/sentry-javascript · GitHub
Skip to content
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ module.exports = {
},
},
{
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['tsconfig.dev.json'],
},
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@ scratch/
# side effects of running AWS lambda layer zip action locally
dist-serverless/
sentry-node-serverless-*.zip
# transpiled transformers
jest/transformers/*.js
# node tarballs
packages/*/sentry-*.tgz
.nxcache
Expand Down
29 changes: 0 additions & 29 deletions .vscode/launch.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,35 +52,6 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
{
"name": "Debug unit tests - just open file",
"type": "node",
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--watch",
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
// you're hitting a single test's breakpoints, in order)
"--runInBand",
// coverage messes up the source maps
"--coverage",
"false",
// remove this to run all package tests
"${relativeFile}"
],
"sourceMaps": true,
"smartStep": true,
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
// "outputCapture" option here; default is to show console logs), but not both
"console": "integratedTerminal",
// since we're not using it, don't automatically switch to it
"internalConsoleOptions": "neverOpen"
},

// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
Expand Down
17 changes: 0 additions & 17 deletions CONTRIBUTING.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `

Note: you must run `yarn build` before `yarn test` will work.

## Debugging Tests

If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.

0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
tab in the sidebar as one of the recommended workspace extensions.

1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
4. Click the green "play" button to run the tests in the open file in watch mode.

Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
part of the buggy test.

## Debug Build Flags

Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/.eslintrc.js
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
module.exports = {
env: {
node: true,
jest: true,
},
extends: ['../../.eslintrc.js'],
overrides: [
Expand Down
6 changes: 2 additions & 4 deletions dev-packages/node-integration-tests/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ folders containing test scenarios and assertions.
`runServer` also accepts an optional `scenarioPath` argument for non-standard usage.

`test.ts` is required for each test case, and contains the server runner logic, request interceptors for Sentry
requests, and assertions. Test server, interceptors and assertions are all run on the same Jest thread.
requests, and assertions. Test server, interceptors and assertions are all run on the same Vitest thread.

### Utilities

Expand All@@ -40,12 +40,10 @@ Tests can be run locally with:

`yarn test`

To run tests with Jest's watch mode:
To run tests with Vitest's watch mode:

`yarn test:watch`

To filter tests by their title:

`yarn test -t "set different properties of a scope"`

You can refer to [Jest documentation](https://jestjs.io/docs/cli) for other CLI options.
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/tsconfig.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,6 @@
"lib": ["DOM", "ES2018"],
// package-specific options
"esModuleInterop": true,
"types": ["node", "jest"]
"types": ["node"]
}
}
43 changes: 0 additions & 43 deletions jest/jest.config.js

This file was deleted.

7 changes: 1 addition & 6 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"circularDepCheck": "lerna run circularDepCheck",
"clean": "run-s clean:build clean:caches",
"clean:build": "lerna run clean",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx",
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
"clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz",
"clean:watchman": "watchman watch-del \".\"",
Expand DownExpand Up@@ -110,17 +110,13 @@
"@rollup/pluginutils": "^5.1.0",
"@size-limit/file": "~11.1.6",
"@size-limit/webpack": "~11.1.6",
"@types/jest": "^27.4.1",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.1",
"@vitest/coverage-v8": "^2.1.8",
"deepmerge": "^4.2.2",
"downlevel-dts": "~0.11.0",
"es-check": "^7.2.1",
"eslint": "7.32.0",
"jest": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-junit": "^16.0.0",
"jsdom": "^21.1.2",
"lerna": "7.1.1",
"madge": "7.0.0",
Expand All@@ -133,7 +129,6 @@
"rollup-plugin-license": "^3.3.1",
"size-limit": "~11.1.6",
"sucrase": "^3.35.0",
"ts-jest": "^27.1.4",
"ts-node": "10.9.1",
"typescript": "~5.0.0",
"vitest": "^2.1.8",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -291,8 +291,6 @@ describe('checkOrSetAlreadyCaught()', () => {

describe('uuid4 generation', () => {
const uuid4Regex = /^[0-9A-F]{12}[4][0-9A-F]{3}[89AB][0-9A-F]{15}$/i;
// Jest messes with the global object, so there is no global crypto object in any node version
// For this reason we need to create our own crypto object for each test to cover all the code paths
it('returns valid uuid v4 ids via Math.random', () => {
for (let index = 0; index < 1_000; index++) {
expect(uuid4()).toMatch(uuid4Regex);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/utils-hoist/normalize.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import { describe, expect, test, vi } from 'vitest';
Expand Down
11 changes: 2 additions & 9 deletions packages/core/test/utils-hoist/object.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import type { WrappedFunction } from '../../src/types-hoist';
Expand DownExpand Up@@ -331,17 +331,10 @@ describe('objectify()', () => {
});

describe('wraps other primitives with their respective object wrapper classes', () => {
// TODO: There's currently a bug in Jest - if you give it the `Boolean` class, it runs `typeof received ===
// 'boolean'` but not `received instanceof Boolean` (the way it correctly does for other primitive wrappers, like
// `Number` and `String). (See https://github.com/facebook/jest/pull/11976.) Once that is fixed and we upgrade jest,
// we can comment the test below back in. (The tests for symbols and bigints are working only because our current
// version of jest is sufficiently old that they're not even considered in the relevant check and just fall to the
// default `instanceof` check jest uses for all unknown classes.)

it.each([
['number', Number, 1121],
['string', String, 'Dogs are great!'],
// ["boolean", Boolean, true],
['boolean', Boolean, true],
['symbol', Symbol, Symbol('Maisey')],
])('%s', (_caseName, wrapperClass, primitive) => {
const objectifiedPrimitive = objectify(primitive);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-sdk/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-simple-import-sort": "^5.0.3"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-config-sdk/src/base.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,10 +154,6 @@ module.exports = {
},
},
{
// Configuration for files in test directories
env: {
jest: true,
},
files: [
'test.ts',
'*.test.ts',
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/tsconfig.plugin.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
// "types": ["node", "jest"]
"declaration": true,
"declarationMap": false,
"emitDeclarationOnly": true,
Expand Down
1 change: 0 additions & 1 deletion packages/node/jest.config.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/node/test/helpers/conditional.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ const NODE_VERSION = parseSemver(process.versions.node).major;
* Returns`describe` or `describe.skip` depending on allowed major versions of Node.
*
* @param {{ min?: number; max?: number }} allowedVersion
* @return {*} {jest.Describe}
*/
export const conditionalTest = (allowedVersion: { min?: number; max?: number }) => {
if (!NODE_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/react-router/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
"types": ["node", "vitest/globals"],
"types": ["node"],
}
}
2 changes: 1 addition & 1 deletion packages/remix/test/integration/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*"],

"compilerOptions": {
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/solidstart/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

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

// other package-specific, test-specific options
"jsx": "preserve",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig-templates/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["jest"]
"types": []

// other package-specific, test-specific options
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.dev.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
{
"extends": "./tsconfig.json",

"include": ["**/scripts/**/*.ts", "jest/**/*.ts", "vite/**/*.ts"],
"include": ["**/scripts/**/*.ts", "vite/**/*.ts"],

"compilerOptions": {
"types": ["node", "jest", "vitest/globals"]
"types": ["node"]
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' chore(jest): Final Jest cleanup by timfish · Pull Request #15549 · getsentry/sentry-javascript · GitHub
Skip to content
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ module.exports = {
},
},
{
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['tsconfig.dev.json'],
},
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@ scratch/
# side effects of running AWS lambda layer zip action locally
dist-serverless/
sentry-node-serverless-*.zip
# transpiled transformers
jest/transformers/*.js
# node tarballs
packages/*/sentry-*.tgz
.nxcache
Expand Down
29 changes: 0 additions & 29 deletions .vscode/launch.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,35 +52,6 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
{
"name": "Debug unit tests - just open file",
"type": "node",
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--watch",
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
// you're hitting a single test's breakpoints, in order)
"--runInBand",
// coverage messes up the source maps
"--coverage",
"false",
// remove this to run all package tests
"${relativeFile}"
],
"sourceMaps": true,
"smartStep": true,
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
// "outputCapture" option here; default is to show console logs), but not both
"console": "integratedTerminal",
// since we're not using it, don't automatically switch to it
"internalConsoleOptions": "neverOpen"
},

// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
Expand Down
17 changes: 0 additions & 17 deletions CONTRIBUTING.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `

Note: you must run `yarn build` before `yarn test` will work.

## Debugging Tests

If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.

0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
tab in the sidebar as one of the recommended workspace extensions.

1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
4. Click the green "play" button to run the tests in the open file in watch mode.

Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
part of the buggy test.

## Debug Build Flags

Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/.eslintrc.js
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
module.exports = {
env: {
node: true,
jest: true,
},
extends: ['../../.eslintrc.js'],
overrides: [
Expand Down
6 changes: 2 additions & 4 deletions dev-packages/node-integration-tests/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ folders containing test scenarios and assertions.
`runServer` also accepts an optional `scenarioPath` argument for non-standard usage.

`test.ts` is required for each test case, and contains the server runner logic, request interceptors for Sentry
requests, and assertions. Test server, interceptors and assertions are all run on the same Jest thread.
requests, and assertions. Test server, interceptors and assertions are all run on the same Vitest thread.

### Utilities

Expand All@@ -40,12 +40,10 @@ Tests can be run locally with:

`yarn test`

To run tests with Jest's watch mode:
To run tests with Vitest's watch mode:

`yarn test:watch`

To filter tests by their title:

`yarn test -t "set different properties of a scope"`

You can refer to [Jest documentation](https://jestjs.io/docs/cli) for other CLI options.
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/tsconfig.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,6 @@
"lib": ["DOM", "ES2018"],
// package-specific options
"esModuleInterop": true,
"types": ["node", "jest"]
"types": ["node"]
}
}
43 changes: 0 additions & 43 deletions jest/jest.config.js

This file was deleted.

7 changes: 1 addition & 6 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"circularDepCheck": "lerna run circularDepCheck",
"clean": "run-s clean:build clean:caches",
"clean:build": "lerna run clean",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx",
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
"clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz",
"clean:watchman": "watchman watch-del \".\"",
Expand DownExpand Up@@ -110,17 +110,13 @@
"@rollup/pluginutils": "^5.1.0",
"@size-limit/file": "~11.1.6",
"@size-limit/webpack": "~11.1.6",
"@types/jest": "^27.4.1",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.1",
"@vitest/coverage-v8": "^2.1.8",
"deepmerge": "^4.2.2",
"downlevel-dts": "~0.11.0",
"es-check": "^7.2.1",
"eslint": "7.32.0",
"jest": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-junit": "^16.0.0",
"jsdom": "^21.1.2",
"lerna": "7.1.1",
"madge": "7.0.0",
Expand All@@ -133,7 +129,6 @@
"rollup-plugin-license": "^3.3.1",
"size-limit": "~11.1.6",
"sucrase": "^3.35.0",
"ts-jest": "^27.1.4",
"ts-node": "10.9.1",
"typescript": "~5.0.0",
"vitest": "^2.1.8",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -291,8 +291,6 @@ describe('checkOrSetAlreadyCaught()', () => {

describe('uuid4 generation', () => {
const uuid4Regex = /^[0-9A-F]{12}[4][0-9A-F]{3}[89AB][0-9A-F]{15}$/i;
// Jest messes with the global object, so there is no global crypto object in any node version
// For this reason we need to create our own crypto object for each test to cover all the code paths
it('returns valid uuid v4 ids via Math.random', () => {
for (let index = 0; index < 1_000; index++) {
expect(uuid4()).toMatch(uuid4Regex);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/utils-hoist/normalize.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import { describe, expect, test, vi } from 'vitest';
Expand Down
11 changes: 2 additions & 9 deletions packages/core/test/utils-hoist/object.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import type { WrappedFunction } from '../../src/types-hoist';
Expand DownExpand Up@@ -331,17 +331,10 @@ describe('objectify()', () => {
});

describe('wraps other primitives with their respective object wrapper classes', () => {
// TODO: There's currently a bug in Jest - if you give it the `Boolean` class, it runs `typeof received ===
// 'boolean'` but not `received instanceof Boolean` (the way it correctly does for other primitive wrappers, like
// `Number` and `String). (See https://github.com/facebook/jest/pull/11976.) Once that is fixed and we upgrade jest,
// we can comment the test below back in. (The tests for symbols and bigints are working only because our current
// version of jest is sufficiently old that they're not even considered in the relevant check and just fall to the
// default `instanceof` check jest uses for all unknown classes.)

it.each([
['number', Number, 1121],
['string', String, 'Dogs are great!'],
// ["boolean", Boolean, true],
['boolean', Boolean, true],
['symbol', Symbol, Symbol('Maisey')],
])('%s', (_caseName, wrapperClass, primitive) => {
const objectifiedPrimitive = objectify(primitive);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-sdk/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-simple-import-sort": "^5.0.3"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-config-sdk/src/base.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,10 +154,6 @@ module.exports = {
},
},
{
// Configuration for files in test directories
env: {
jest: true,
},
files: [
'test.ts',
'*.test.ts',
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/tsconfig.plugin.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
// "types": ["node", "jest"]
"declaration": true,
"declarationMap": false,
"emitDeclarationOnly": true,
Expand Down
1 change: 0 additions & 1 deletion packages/node/jest.config.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/node/test/helpers/conditional.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ const NODE_VERSION = parseSemver(process.versions.node).major;
* Returns`describe` or `describe.skip` depending on allowed major versions of Node.
*
* @param {{ min?: number; max?: number }} allowedVersion
* @return {*} {jest.Describe}
*/
export const conditionalTest = (allowedVersion: { min?: number; max?: number }) => {
if (!NODE_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/react-router/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
"types": ["node", "vitest/globals"],
"types": ["node"],
}
}
2 changes: 1 addition & 1 deletion packages/remix/test/integration/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*"],

"compilerOptions": {
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/solidstart/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

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

// other package-specific, test-specific options
"jsx": "preserve",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig-templates/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["jest"]
"types": []

// other package-specific, test-specific options
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.dev.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
{
"extends": "./tsconfig.json",

"include": ["**/scripts/**/*.ts", "jest/**/*.ts", "vite/**/*.ts"],
"include": ["**/scripts/**/*.ts", "vite/**/*.ts"],

"compilerOptions": {
"types": ["node", "jest", "vitest/globals"]
"types": ["node"]
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(jest): Final Jest cleanup by timfish · Pull Request #15549 · getsentry/sentry-javascript · GitHub
Skip to content
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ module.exports = {
},
},
{
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['tsconfig.dev.json'],
},
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@ scratch/
# side effects of running AWS lambda layer zip action locally
dist-serverless/
sentry-node-serverless-*.zip
# transpiled transformers
jest/transformers/*.js
# node tarballs
packages/*/sentry-*.tgz
.nxcache
Expand Down
29 changes: 0 additions & 29 deletions .vscode/launch.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,35 +52,6 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
{
"name": "Debug unit tests - just open file",
"type": "node",
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--watch",
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
// you're hitting a single test's breakpoints, in order)
"--runInBand",
// coverage messes up the source maps
"--coverage",
"false",
// remove this to run all package tests
"${relativeFile}"
],
"sourceMaps": true,
"smartStep": true,
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
// "outputCapture" option here; default is to show console logs), but not both
"console": "integratedTerminal",
// since we're not using it, don't automatically switch to it
"internalConsoleOptions": "neverOpen"
},

// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
Expand Down
17 changes: 0 additions & 17 deletions CONTRIBUTING.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `

Note: you must run `yarn build` before `yarn test` will work.

## Debugging Tests

If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.

0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
tab in the sidebar as one of the recommended workspace extensions.

1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
4. Click the green "play" button to run the tests in the open file in watch mode.

Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
part of the buggy test.

## Debug Build Flags

Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/.eslintrc.js
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
module.exports = {
env: {
node: true,
jest: true,
},
extends: ['../../.eslintrc.js'],
overrides: [
Expand Down
6 changes: 2 additions & 4 deletions dev-packages/node-integration-tests/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ folders containing test scenarios and assertions.
`runServer` also accepts an optional `scenarioPath` argument for non-standard usage.

`test.ts` is required for each test case, and contains the server runner logic, request interceptors for Sentry
requests, and assertions. Test server, interceptors and assertions are all run on the same Jest thread.
requests, and assertions. Test server, interceptors and assertions are all run on the same Vitest thread.

### Utilities

Expand All@@ -40,12 +40,10 @@ Tests can be run locally with:

`yarn test`

To run tests with Jest's watch mode:
To run tests with Vitest's watch mode:

`yarn test:watch`

To filter tests by their title:

`yarn test -t "set different properties of a scope"`

You can refer to [Jest documentation](https://jestjs.io/docs/cli) for other CLI options.
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/tsconfig.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,6 @@
"lib": ["DOM", "ES2018"],
// package-specific options
"esModuleInterop": true,
"types": ["node", "jest"]
"types": ["node"]
}
}
43 changes: 0 additions & 43 deletions jest/jest.config.js

This file was deleted.

7 changes: 1 addition & 6 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"circularDepCheck": "lerna run circularDepCheck",
"clean": "run-s clean:build clean:caches",
"clean:build": "lerna run clean",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx",
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
"clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz",
"clean:watchman": "watchman watch-del \".\"",
Expand DownExpand Up@@ -110,17 +110,13 @@
"@rollup/pluginutils": "^5.1.0",
"@size-limit/file": "~11.1.6",
"@size-limit/webpack": "~11.1.6",
"@types/jest": "^27.4.1",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.1",
"@vitest/coverage-v8": "^2.1.8",
"deepmerge": "^4.2.2",
"downlevel-dts": "~0.11.0",
"es-check": "^7.2.1",
"eslint": "7.32.0",
"jest": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-junit": "^16.0.0",
"jsdom": "^21.1.2",
"lerna": "7.1.1",
"madge": "7.0.0",
Expand All@@ -133,7 +129,6 @@
"rollup-plugin-license": "^3.3.1",
"size-limit": "~11.1.6",
"sucrase": "^3.35.0",
"ts-jest": "^27.1.4",
"ts-node": "10.9.1",
"typescript": "~5.0.0",
"vitest": "^2.1.8",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -291,8 +291,6 @@ describe('checkOrSetAlreadyCaught()', () => {

describe('uuid4 generation', () => {
const uuid4Regex = /^[0-9A-F]{12}[4][0-9A-F]{3}[89AB][0-9A-F]{15}$/i;
// Jest messes with the global object, so there is no global crypto object in any node version
// For this reason we need to create our own crypto object for each test to cover all the code paths
it('returns valid uuid v4 ids via Math.random', () => {
for (let index = 0; index < 1_000; index++) {
expect(uuid4()).toMatch(uuid4Regex);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/utils-hoist/normalize.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import { describe, expect, test, vi } from 'vitest';
Expand Down
11 changes: 2 additions & 9 deletions packages/core/test/utils-hoist/object.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import type { WrappedFunction } from '../../src/types-hoist';
Expand DownExpand Up@@ -331,17 +331,10 @@ describe('objectify()', () => {
});

describe('wraps other primitives with their respective object wrapper classes', () => {
// TODO: There's currently a bug in Jest - if you give it the `Boolean` class, it runs `typeof received ===
// 'boolean'` but not `received instanceof Boolean` (the way it correctly does for other primitive wrappers, like
// `Number` and `String). (See https://github.com/facebook/jest/pull/11976.) Once that is fixed and we upgrade jest,
// we can comment the test below back in. (The tests for symbols and bigints are working only because our current
// version of jest is sufficiently old that they're not even considered in the relevant check and just fall to the
// default `instanceof` check jest uses for all unknown classes.)

it.each([
['number', Number, 1121],
['string', String, 'Dogs are great!'],
// ["boolean", Boolean, true],
['boolean', Boolean, true],
['symbol', Symbol, Symbol('Maisey')],
])('%s', (_caseName, wrapperClass, primitive) => {
const objectifiedPrimitive = objectify(primitive);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-sdk/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-simple-import-sort": "^5.0.3"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-config-sdk/src/base.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,10 +154,6 @@ module.exports = {
},
},
{
// Configuration for files in test directories
env: {
jest: true,
},
files: [
'test.ts',
'*.test.ts',
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/tsconfig.plugin.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
// "types": ["node", "jest"]
"declaration": true,
"declarationMap": false,
"emitDeclarationOnly": true,
Expand Down
1 change: 0 additions & 1 deletion packages/node/jest.config.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/node/test/helpers/conditional.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ const NODE_VERSION = parseSemver(process.versions.node).major;
* Returns`describe` or `describe.skip` depending on allowed major versions of Node.
*
* @param {{ min?: number; max?: number }} allowedVersion
* @return {*} {jest.Describe}
*/
export const conditionalTest = (allowedVersion: { min?: number; max?: number }) => {
if (!NODE_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/react-router/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
"types": ["node", "vitest/globals"],
"types": ["node"],
}
}
2 changes: 1 addition & 1 deletion packages/remix/test/integration/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*"],

"compilerOptions": {
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/solidstart/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

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

// other package-specific, test-specific options
"jsx": "preserve",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig-templates/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["jest"]
"types": []

// other package-specific, test-specific options
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.dev.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
{
"extends": "./tsconfig.json",

"include": ["**/scripts/**/*.ts", "jest/**/*.ts", "vite/**/*.ts"],
"include": ["**/scripts/**/*.ts", "vite/**/*.ts"],

"compilerOptions": {
"types": ["node", "jest", "vitest/globals"]
"types": ["node"]
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(jest): Final Jest cleanup by timfish · Pull Request #15549 · getsentry/sentry-javascript · GitHub
Skip to content
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ module.exports = {
},
},
{
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['tsconfig.dev.json'],
},
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@ scratch/
# side effects of running AWS lambda layer zip action locally
dist-serverless/
sentry-node-serverless-*.zip
# transpiled transformers
jest/transformers/*.js
# node tarballs
packages/*/sentry-*.tgz
.nxcache
Expand Down
29 changes: 0 additions & 29 deletions .vscode/launch.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,35 +52,6 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
{
"name": "Debug unit tests - just open file",
"type": "node",
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--watch",
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
// you're hitting a single test's breakpoints, in order)
"--runInBand",
// coverage messes up the source maps
"--coverage",
"false",
// remove this to run all package tests
"${relativeFile}"
],
"sourceMaps": true,
"smartStep": true,
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
// "outputCapture" option here; default is to show console logs), but not both
"console": "integratedTerminal",
// since we're not using it, don't automatically switch to it
"internalConsoleOptions": "neverOpen"
},

// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
Expand Down
17 changes: 0 additions & 17 deletions CONTRIBUTING.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `

Note: you must run `yarn build` before `yarn test` will work.

## Debugging Tests

If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.

0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
tab in the sidebar as one of the recommended workspace extensions.

1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
4. Click the green "play" button to run the tests in the open file in watch mode.

Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
part of the buggy test.

## Debug Build Flags

Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/.eslintrc.js
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
module.exports = {
env: {
node: true,
jest: true,
},
extends: ['../../.eslintrc.js'],
overrides: [
Expand Down
6 changes: 2 additions & 4 deletions dev-packages/node-integration-tests/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ folders containing test scenarios and assertions.
`runServer` also accepts an optional `scenarioPath` argument for non-standard usage.

`test.ts` is required for each test case, and contains the server runner logic, request interceptors for Sentry
requests, and assertions. Test server, interceptors and assertions are all run on the same Jest thread.
requests, and assertions. Test server, interceptors and assertions are all run on the same Vitest thread.

### Utilities

Expand All@@ -40,12 +40,10 @@ Tests can be run locally with:

`yarn test`

To run tests with Jest's watch mode:
To run tests with Vitest's watch mode:

`yarn test:watch`

To filter tests by their title:

`yarn test -t "set different properties of a scope"`

You can refer to [Jest documentation](https://jestjs.io/docs/cli) for other CLI options.
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/tsconfig.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,6 @@
"lib": ["DOM", "ES2018"],
// package-specific options
"esModuleInterop": true,
"types": ["node", "jest"]
"types": ["node"]
}
}
43 changes: 0 additions & 43 deletions jest/jest.config.js

This file was deleted.

7 changes: 1 addition & 6 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"circularDepCheck": "lerna run circularDepCheck",
"clean": "run-s clean:build clean:caches",
"clean:build": "lerna run clean",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx",
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
"clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz",
"clean:watchman": "watchman watch-del \".\"",
Expand DownExpand Up@@ -110,17 +110,13 @@
"@rollup/pluginutils": "^5.1.0",
"@size-limit/file": "~11.1.6",
"@size-limit/webpack": "~11.1.6",
"@types/jest": "^27.4.1",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.1",
"@vitest/coverage-v8": "^2.1.8",
"deepmerge": "^4.2.2",
"downlevel-dts": "~0.11.0",
"es-check": "^7.2.1",
"eslint": "7.32.0",
"jest": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-junit": "^16.0.0",
"jsdom": "^21.1.2",
"lerna": "7.1.1",
"madge": "7.0.0",
Expand All@@ -133,7 +129,6 @@
"rollup-plugin-license": "^3.3.1",
"size-limit": "~11.1.6",
"sucrase": "^3.35.0",
"ts-jest": "^27.1.4",
"ts-node": "10.9.1",
"typescript": "~5.0.0",
"vitest": "^2.1.8",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -291,8 +291,6 @@ describe('checkOrSetAlreadyCaught()', () => {

describe('uuid4 generation', () => {
const uuid4Regex = /^[0-9A-F]{12}[4][0-9A-F]{3}[89AB][0-9A-F]{15}$/i;
// Jest messes with the global object, so there is no global crypto object in any node version
// For this reason we need to create our own crypto object for each test to cover all the code paths
it('returns valid uuid v4 ids via Math.random', () => {
for (let index = 0; index < 1_000; index++) {
expect(uuid4()).toMatch(uuid4Regex);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/utils-hoist/normalize.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import { describe, expect, test, vi } from 'vitest';
Expand Down
11 changes: 2 additions & 9 deletions packages/core/test/utils-hoist/object.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import type { WrappedFunction } from '../../src/types-hoist';
Expand DownExpand Up@@ -331,17 +331,10 @@ describe('objectify()', () => {
});

describe('wraps other primitives with their respective object wrapper classes', () => {
// TODO: There's currently a bug in Jest - if you give it the `Boolean` class, it runs `typeof received ===
// 'boolean'` but not `received instanceof Boolean` (the way it correctly does for other primitive wrappers, like
// `Number` and `String). (See https://github.com/facebook/jest/pull/11976.) Once that is fixed and we upgrade jest,
// we can comment the test below back in. (The tests for symbols and bigints are working only because our current
// version of jest is sufficiently old that they're not even considered in the relevant check and just fall to the
// default `instanceof` check jest uses for all unknown classes.)

it.each([
['number', Number, 1121],
['string', String, 'Dogs are great!'],
// ["boolean", Boolean, true],
['boolean', Boolean, true],
['symbol', Symbol, Symbol('Maisey')],
])('%s', (_caseName, wrapperClass, primitive) => {
const objectifiedPrimitive = objectify(primitive);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-sdk/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-simple-import-sort": "^5.0.3"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-config-sdk/src/base.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,10 +154,6 @@ module.exports = {
},
},
{
// Configuration for files in test directories
env: {
jest: true,
},
files: [
'test.ts',
'*.test.ts',
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/tsconfig.plugin.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
// "types": ["node", "jest"]
"declaration": true,
"declarationMap": false,
"emitDeclarationOnly": true,
Expand Down
1 change: 0 additions & 1 deletion packages/node/jest.config.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/node/test/helpers/conditional.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ const NODE_VERSION = parseSemver(process.versions.node).major;
* Returns`describe` or `describe.skip` depending on allowed major versions of Node.
*
* @param {{ min?: number; max?: number }} allowedVersion
* @return {*} {jest.Describe}
*/
export const conditionalTest = (allowedVersion: { min?: number; max?: number }) => {
if (!NODE_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/react-router/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
"types": ["node", "vitest/globals"],
"types": ["node"],
}
}
2 changes: 1 addition & 1 deletion packages/remix/test/integration/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*"],

"compilerOptions": {
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/solidstart/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

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

// other package-specific, test-specific options
"jsx": "preserve",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig-templates/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["jest"]
"types": []

// other package-specific, test-specific options
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.dev.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
{
"extends": "./tsconfig.json",

"include": ["**/scripts/**/*.ts", "jest/**/*.ts", "vite/**/*.ts"],
"include": ["**/scripts/**/*.ts", "vite/**/*.ts"],

"compilerOptions": {
"types": ["node", "jest", "vitest/globals"]
"types": ["node"]
}
}
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); chore(jest): Final Jest cleanup by timfish · Pull Request #15549 · getsentry/sentry-javascript · GitHub
Skip to content
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ module.exports = {
},
},
{
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['tsconfig.dev.json'],
},
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@ scratch/
# side effects of running AWS lambda layer zip action locally
dist-serverless/
sentry-node-serverless-*.zip
# transpiled transformers
jest/transformers/*.js
# node tarballs
packages/*/sentry-*.tgz
.nxcache
Expand Down
29 changes: 0 additions & 29 deletions .vscode/launch.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,35 +52,6 @@
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
{
"name": "Debug unit tests - just open file",
"type": "node",
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"--watch",
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
// you're hitting a single test's breakpoints, in order)
"--runInBand",
// coverage messes up the source maps
"--coverage",
"false",
// remove this to run all package tests
"${relativeFile}"
],
"sourceMaps": true,
"smartStep": true,
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
// "outputCapture" option here; default is to show console logs), but not both
"console": "integratedTerminal",
// since we're not using it, don't automatically switch to it
"internalConsoleOptions": "neverOpen"
},

// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
// install the recommended extension Tasks Shell Input.
Expand Down
17 changes: 0 additions & 17 deletions CONTRIBUTING.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `

Note: you must run `yarn build` before `yarn test` will work.

## Debugging Tests

If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.

0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
tab in the sidebar as one of the recommended workspace extensions.

1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
4. Click the green "play" button to run the tests in the open file in watch mode.

Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
part of the buggy test.

## Debug Build Flags

Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:
Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/.eslintrc.js
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
module.exports = {
env: {
node: true,
jest: true,
},
extends: ['../../.eslintrc.js'],
overrides: [
Expand Down
6 changes: 2 additions & 4 deletions dev-packages/node-integration-tests/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ folders containing test scenarios and assertions.
`runServer` also accepts an optional `scenarioPath` argument for non-standard usage.

`test.ts` is required for each test case, and contains the server runner logic, request interceptors for Sentry
requests, and assertions. Test server, interceptors and assertions are all run on the same Jest thread.
requests, and assertions. Test server, interceptors and assertions are all run on the same Vitest thread.

### Utilities

Expand All@@ -40,12 +40,10 @@ Tests can be run locally with:

`yarn test`

To run tests with Jest's watch mode:
To run tests with Vitest's watch mode:

`yarn test:watch`

To filter tests by their title:

`yarn test -t "set different properties of a scope"`

You can refer to [Jest documentation](https://jestjs.io/docs/cli) for other CLI options.
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/tsconfig.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,6 @@
"lib": ["DOM", "ES2018"],
// package-specific options
"esModuleInterop": true,
"types": ["node", "jest"]
"types": ["node"]
}
}
43 changes: 0 additions & 43 deletions jest/jest.config.js

This file was deleted.

7 changes: 1 addition & 6 deletions package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
"circularDepCheck": "lerna run circularDepCheck",
"clean": "run-s clean:build clean:caches",
"clean:build": "lerna run clean",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache",
"clean:caches": "yarn rimraf eslintcache .nxcache .nx",
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
"clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz",
"clean:watchman": "watchman watch-del \".\"",
Expand DownExpand Up@@ -110,17 +110,13 @@
"@rollup/pluginutils": "^5.1.0",
"@size-limit/file": "~11.1.6",
"@size-limit/webpack": "~11.1.6",
"@types/jest": "^27.4.1",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.1",
"@vitest/coverage-v8": "^2.1.8",
"deepmerge": "^4.2.2",
"downlevel-dts": "~0.11.0",
"es-check": "^7.2.1",
"eslint": "7.32.0",
"jest": "^27.5.1",
"jest-environment-node": "^27.5.1",
"jest-junit": "^16.0.0",
"jsdom": "^21.1.2",
"lerna": "7.1.1",
"madge": "7.0.0",
Expand All@@ -133,7 +129,6 @@
"rollup-plugin-license": "^3.3.1",
"size-limit": "~11.1.6",
"sucrase": "^3.35.0",
"ts-jest": "^27.1.4",
"ts-node": "10.9.1",
"typescript": "~5.0.0",
"vitest": "^2.1.8",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -291,8 +291,6 @@ describe('checkOrSetAlreadyCaught()', () => {

describe('uuid4 generation', () => {
const uuid4Regex = /^[0-9A-F]{12}[4][0-9A-F]{3}[89AB][0-9A-F]{15}$/i;
// Jest messes with the global object, so there is no global crypto object in any node version
// For this reason we need to create our own crypto object for each test to cover all the code paths
it('returns valid uuid v4 ids via Math.random', () => {
for (let index = 0; index < 1_000; index++) {
expect(uuid4()).toMatch(uuid4Regex);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/utils-hoist/normalize.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import { describe, expect, test, vi } from 'vitest';
Expand Down
11 changes: 2 additions & 9 deletions packages/core/test/utils-hoist/object.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
/**
* @jest-environment jsdom
* @vitest-environment jsdom
*/

import type { WrappedFunction } from '../../src/types-hoist';
Expand DownExpand Up@@ -331,17 +331,10 @@ describe('objectify()', () => {
});

describe('wraps other primitives with their respective object wrapper classes', () => {
// TODO: There's currently a bug in Jest - if you give it the `Boolean` class, it runs `typeof received ===
// 'boolean'` but not `received instanceof Boolean` (the way it correctly does for other primitive wrappers, like
// `Number` and `String). (See https://github.com/facebook/jest/pull/11976.) Once that is fixed and we upgrade jest,
// we can comment the test below back in. (The tests for symbols and bigints are working only because our current
// version of jest is sufficiently old that they're not even considered in the relevant check and just fall to the
// default `instanceof` check jest uses for all unknown classes.)

it.each([
['number', Number, 1121],
['string', String, 'Dogs are great!'],
// ["boolean", Boolean, true],
['boolean', Boolean, true],
['symbol', Symbol, Symbol('Maisey')],
])('%s', (_caseName, wrapperClass, primitive) => {
const objectifiedPrimitive = objectify(primitive);
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-sdk/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jsdoc": "^30.0.3",
"eslint-plugin-simple-import-sort": "^5.0.3"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-config-sdk/src/base.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,10 +154,6 @@ module.exports = {
},
},
{
// Configuration for files in test directories
env: {
jest: true,
},
files: [
'test.ts',
'*.test.ts',
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/tsconfig.plugin.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
// "types": ["node", "jest"]
"declaration": true,
"declarationMap": false,
"emitDeclarationOnly": true,
Expand Down
1 change: 0 additions & 1 deletion packages/node/jest.config.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/node/test/helpers/conditional.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ const NODE_VERSION = parseSemver(process.versions.node).major;
* Returns`describe` or `describe.skip` depending on allowed major versions of Node.
*
* @param {{ min?: number; max?: number }} allowedVersion
* @return {*} {jest.Describe}
*/
export const conditionalTest = (allowedVersion: { min?: number; max?: number }) => {
if (!NODE_VERSION) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,6 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/react-router/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
"types": ["node", "vitest/globals"],
"types": ["node"],
}
}
2 changes: 1 addition & 1 deletion packages/remix/test/integration/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,6 @@
"include": ["test/**/*"],

"compilerOptions": {
"types": ["node", "vitest/globals"]
"types": ["node"]
}
}
2 changes: 1 addition & 1 deletion packages/solidstart/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

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

// other package-specific, test-specific options
"jsx": "preserve",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig-templates/tsconfig.test.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["jest"]
"types": []

// other package-specific, test-specific options
}
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.dev.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
{
"extends": "./tsconfig.json",

"include": ["**/scripts/**/*.ts", "jest/**/*.ts", "vite/**/*.ts"],
"include": ["**/scripts/**/*.ts", "vite/**/*.ts"],

"compilerOptions": {
"types": ["node", "jest", "vitest/globals"]
"types": ["node"]
}
}
Loading