Skip to content

Commit c38315e

Browse files
authored
chore(jest): Final Jest cleanup (#15549)
resolves #11084
1 parent 12c5e73 commit c38315e

File tree

24 files changed

+121
-1358
lines changed

24 files changed

+121
-1358
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = {
3838
},
3939
},
4040
{
41-
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
41+
files: ['scripts/**/*.ts'],
4242
parserOptions: {
4343
project: ['tsconfig.dev.json'],
4444
},

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ scratch/
1717
# side effects of running AWS lambda layer zip action locally
1818
dist-serverless/
1919
sentry-node-serverless-*.zip
20-
# transpiled transformers
21-
jest/transformers/*.js
2220
# node tarballs
2321
packages/*/sentry-*.tgz
2422
.nxcache

.vscode/launch.json

-29
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,6 @@
5252
"internalConsoleOptions": "openOnSessionStart",
5353
"outputCapture": "std"
5454
},
55-
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
56-
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
57-
// install the recommended extension Tasks Shell Input.
58-
{
59-
"name": "Debug unit tests - just open file",
60-
"type": "node",
61-
"cwd": "${workspaceFolder}/packages/${input:getPackageName}",
62-
"request": "launch",
63-
"program": "${workspaceFolder}/node_modules/.bin/jest",
64-
"args": [
65-
"--watch",
66-
// this runs one test at a time, rather than running them in parallel (necessary for debugging so that you know
67-
// you're hitting a single test's breakpoints, in order)
68-
"--runInBand",
69-
// coverage messes up the source maps
70-
"--coverage",
71-
"false",
72-
// remove this to run all package tests
73-
"${relativeFile}"
74-
],
75-
"sourceMaps": true,
76-
"smartStep": true,
77-
// otherwise it goes to the VSCode debug terminal, which prints the test output or console logs (depending on
78-
// "outputCapture" option here; default is to show console logs), but not both
79-
"console": "integratedTerminal",
80-
// since we're not using it, don't automatically switch to it
81-
"internalConsoleOptions": "neverOpen"
82-
},
83-
8455
// Run a specific test file in watch mode (must have file in currently active tab when hitting the play button).
8556
// NOTE: If you try to run this and VSCode complains that the command `shellCommand.execute` can't be found, go
8657
// install the recommended extension Tasks Shell Input.

CONTRIBUTING.md

-17
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,6 @@ the tests in each location. Check out the `scripts` entry of the corresponding `
7373

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

76-
## Debugging Tests
77-
78-
If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.
79-
80-
0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions
81-
tab in the sidebar as one of the recommended workspace extensions.
82-
83-
1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
84-
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
85-
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
86-
4. Click the green "play" button to run the tests in the open file in watch mode.
87-
88-
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
89-
those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's
90-
initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are
91-
part of the buggy test.
92-
9376
## Debug Build Flags
9477

9578
Throughout the codebase, you will find a `__DEBUG_BUILD__` constant. This flag serves two purposes:

dev-packages/node-integration-tests/.eslintrc.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module.exports = {
22
env: {
33
node: true,
4-
jest: true,
54
},
65
extends: ['../../.eslintrc.js'],
76
overrides: [

dev-packages/node-integration-tests/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ folders containing test scenarios and assertions.
2323
`runServer` also accepts an optional `scenarioPath` argument for non-standard usage.
2424

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

2828
### Utilities
2929

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

4141
`yarn test`
4242

43-
To run tests with Jest's watch mode:
43+
To run tests with Vitest's watch mode:
4444

4545
`yarn test:watch`
4646

4747
To filter tests by their title:
4848

4949
`yarn test -t "set different properties of a scope"`
50-
51-
You can refer to [Jest documentation](https://jestjs.io/docs/cli) for other CLI options.

dev-packages/node-integration-tests/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"lib": ["DOM", "ES2018"],
1010
// package-specific options
1111
"esModuleInterop": true,
12-
"types": ["node", "jest"]
12+
"types": ["node"]
1313
}
1414
}

jest/jest.config.js

-43
This file was deleted.

package.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"circularDepCheck": "lerna run circularDepCheck",
1616
"clean": "run-s clean:build clean:caches",
1717
"clean:build": "lerna run clean",
18-
"clean:caches": "yarn rimraf eslintcache .nxcache .nx && yarn jest --clearCache",
18+
"clean:caches": "yarn rimraf eslintcache .nxcache .nx",
1919
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
2020
"clean:tarballs": "rimraf {packages,dev-packages}/*/*.tgz",
2121
"clean:watchman": "watchman watch-del \".\"",
@@ -110,17 +110,13 @@
110110
"@rollup/pluginutils": "^5.1.0",
111111
"@size-limit/file": "~11.1.6",
112112
"@size-limit/webpack": "~11.1.6",
113-
"@types/jest": "^27.4.1",
114113
"@types/jsdom": "^21.1.6",
115114
"@types/node": "^18.19.1",
116115
"@vitest/coverage-v8": "^2.1.8",
117116
"deepmerge": "^4.2.2",
118117
"downlevel-dts": "~0.11.0",
119118
"es-check": "^7.2.1",
120119
"eslint": "7.32.0",
121-
"jest": "^27.5.1",
122-
"jest-environment-node": "^27.5.1",
123-
"jest-junit": "^16.0.0",
124120
"jsdom": "^21.1.2",
125121
"lerna": "7.1.1",
126122
"madge": "7.0.0",
@@ -133,7 +129,6 @@
133129
"rollup-plugin-license": "^3.3.1",
134130
"size-limit": "~11.1.6",
135131
"sucrase": "^3.35.0",
136-
"ts-jest": "^27.1.4",
137132
"ts-node": "10.9.1",
138133
"typescript": "~5.0.0",
139134
"vitest": "^2.1.8",

packages/core/test/utils-hoist/misc.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ describe('checkOrSetAlreadyCaught()', () => {
291291

292292
describe('uuid4 generation', () => {
293293
const uuid4Regex = /^[0-9A-F]{12}[4][0-9A-F]{3}[89AB][0-9A-F]{15}$/i;
294-
// Jest messes with the global object, so there is no global crypto object in any node version
295-
// For this reason we need to create our own crypto object for each test to cover all the code paths
296294
it('returns valid uuid v4 ids via Math.random', () => {
297295
for (let index = 0; index < 1_000; index++) {
298296
expect(uuid4()).toMatch(uuid4Regex);

packages/core/test/utils-hoist/normalize.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @jest-environment jsdom
2+
* @vitest-environment jsdom
33
*/
44

55
import { describe, expect, test, vi } from 'vitest';

packages/core/test/utils-hoist/object.test.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @jest-environment jsdom
2+
* @vitest-environment jsdom
33
*/
44

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

333333
describe('wraps other primitives with their respective object wrapper classes', () => {
334-
// TODO: There's currently a bug in Jest - if you give it the `Boolean` class, it runs `typeof received ===
335-
// 'boolean'` but not `received instanceof Boolean` (the way it correctly does for other primitive wrappers, like
336-
// `Number` and `String). (See https://github.com/facebook/jest/pull/11976.) Once that is fixed and we upgrade jest,
337-
// we can comment the test below back in. (The tests for symbols and bigints are working only because our current
338-
// version of jest is sufficiently old that they're not even considered in the relevant check and just fall to the
339-
// default `instanceof` check jest uses for all unknown classes.)
340-
341334
it.each([
342335
['number', Number, 1121],
343336
['string', String, 'Dogs are great!'],
344-
// ["boolean", Boolean, true],
337+
['boolean', Boolean, true],
345338
['symbol', Symbol, Symbol('Maisey')],
346339
])('%s', (_caseName, wrapperClass, primitive) => {
347340
const objectifiedPrimitive = objectify(primitive);

packages/eslint-config-sdk/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"eslint-config-prettier": "^6.11.0",
3030
"eslint-plugin-deprecation": "^1.5.0",
3131
"eslint-plugin-import": "^2.22.0",
32-
"eslint-plugin-jest": "^27.2.2",
3332
"eslint-plugin-jsdoc": "^30.0.3",
3433
"eslint-plugin-simple-import-sort": "^5.0.3"
3534
},

packages/eslint-config-sdk/src/base.js

-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,6 @@ module.exports = {
154154
},
155155
},
156156
{
157-
// Configuration for files in test directories
158-
env: {
159-
jest: true,
160-
},
161157
files: [
162158
'test.ts',
163159
'*.test.ts',

packages/gatsby/tsconfig.plugin.json

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
"compilerOptions": {
77
// should include all types from `./tsconfig.json` plus types for all test frameworks used
8-
// "types": ["node", "jest"]
98
"declaration": true,
109
"declarationMap": false,
1110
"emitDeclarationOnly": true,

packages/node/jest.config.js

-1
This file was deleted.

packages/node/test/helpers/conditional.ts

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const NODE_VERSION = parseSemver(process.versions.node).major;
77
* Returns`describe` or `describe.skip` depending on allowed major versions of Node.
88
*
99
* @param {{ min?: number; max?: number }} allowedVersion
10-
* @return {*} {jest.Describe}
1110
*/
1211
export const conditionalTest = (allowedVersion: { min?: number; max?: number }) => {
1312
if (!NODE_VERSION) {

packages/nuxt/tsconfig.test.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
"compilerOptions": {
77
// should include all types from `./tsconfig.json` plus types for all test frameworks used
8-
"types": ["node", "vitest/globals"]
8+
"types": ["node"]
99
}
1010
}

packages/react-router/tsconfig.test.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"include": ["test/**/*", "vite.config.ts"],
55

66
"compilerOptions": {
7-
"types": ["node", "vitest/globals"],
7+
"types": ["node"],
88
}
99
}

packages/remix/test/integration/tsconfig.test.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"include": ["test/**/*"],
55

66
"compilerOptions": {
7-
"types": ["node", "vitest/globals"]
7+
"types": ["node"]
88
}
99
}

packages/solidstart/tsconfig.test.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

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

tsconfig-templates/tsconfig.test.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
"compilerOptions": {
77
// should include all types from `./tsconfig.json` plus types for all test frameworks used
8-
"types": ["jest"]
8+
"types": []
99

1010
// other package-specific, test-specific options
1111
}

tsconfig.dev.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
{
33
"extends": "./tsconfig.json",
44

5-
"include": ["**/scripts/**/*.ts", "jest/**/*.ts", "vite/**/*.ts"],
5+
"include": ["**/scripts/**/*.ts", "vite/**/*.ts"],
66

77
"compilerOptions": {
8-
"types": ["node", "jest", "vitest/globals"]
8+
"types": ["node"]
99
}
1010
}

0 commit comments

Comments
 (0)