Skip to content

ref(tests): Share test tooling across workspace packages - #127153

Merged
TkDodo merged 32 commits into
masterfrom
tkdodo/ref/shared-test-utils
Oct 15, 2026
Merged

TkDodo merged 32 commits into
masterfrom
tkdodo/ref/shared-test-utils

Conversation

@TkDodo

@TkDodo TkDodo commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Icons and Scraps now use a shared private test-utils package for the Jest runner, jsdom environment, matchers, React Testing Library APIs, and style assertions. The package owns these dependencies, which removes repeated declarations from both consumers and moves jsdom and the abstract Jest jsdom environment out of the root manifest.

The typed Jest configuration accepts consumer setup and overrides. Theme wrappers and app providers stay with their owners, so apps can adopt the same tooling without adding package cycles. The root test command also uses the shared runner.

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 11, 2026
@TkDodo
TkDodo changed the base branch from tkdodo/ref/app-workspace-package to tkdodo/ref/remove-cross-import-aliases October 11, 2026 15:04
@TkDodo
TkDodo added this pull request to stack #126844 October 11, 2026 15:04
Base automatically changed from tkdodo/ref/remove-cross-import-aliases to master October 12, 2026 09:03
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

if [ "$scope" == "scoped" ]; then
# shellcheck disable=SC2086
JEST_TESTS="$(pnpm exec jest --listTests --json --findRelatedTests $FRONTEND_ALL_FILES | jq '.')"
JEST_TESTS="$(pnpm exec sentry-test --listTests --json --findRelatedTests $FRONTEND_ALL_FILES | jq '.')"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: sentry-test is the executable exposed from the test/js package.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of me thinks we should roll these all up into a vite-plus like CLI eventually...

Comment thread tests/js/setup.ts
})),
}));

jest.mock('@stripe/stripe-js', () => ({

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to the getsentry jest setup

Comment thread knip.config.ts
Comment on lines +120 to +122
'@sentry-internal/global-search', // jest.mock does not count as an import.
'@tanstack/react-pacer', // loaded with requireActual
'echarts-for-react', // jest.mock in setup.ts

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread package.json
Comment on lines +123 to +124
"sentry-fixture": "workspace:@sentry-internal/sentry-test@*",
"sentry-test": "workspace:@sentry-internal/sentry-test@*",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: I’m not a fan of this, but it’s what currently produces the least amount of changes. We import from both sentry-fixtures and sentry-test, but they point to the same package.

Ideally, we’d split that up into two packages or unify the imports to just be sentry-test and maybe sentry-test/fixtures/*. But both mean changing lots of entry points, so I’m leaving that for a follow-up

@TkDodo

TkDodo commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread package.json Resolved
# Conflicts:
#	package.json
#	pnpm-lock.yaml
@TkDodo
TkDodo deleted the branch master October 14, 2026 07:03
@TkDodo TkDodo closed this Oct 14, 2026
@TkDodo TkDodo reopened this Oct 14, 2026
@TkDodo
TkDodo removed this pull request from stack #126844 October 14, 2026 09:24
@TkDodo
TkDodo changed the base branch from tkdodo/ref/remove-cross-import-aliases to master October 14, 2026 09:24
@TkDodo
TkDodo added this pull request to stack #127363 October 14, 2026 09:24
@TkDodo

TkDodo commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

},
"scripts": {
"test": "node ../../../scripts/test.js --config jest.config.mjs",
"test": "NODE_ENV=test jest --config jest.config.mjs",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it intentional that these aren't using --watch like the application packages?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll streamline this in a follow-up. adding --watch will likely mean more changes in the CI script to take it away again. I’m not sure who actually runs test locally in watch mode? So maybe it’s best to just remove this and tell AI to append --watch if it wants this.

Comment thread pnpm-workspace.yaml
- static/packages/icons
- static/packages/scraps
- tests/js
- tests/js/getsentry-test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: i find the nesting of getsentry-test a bit odd

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, me too. I just didn’t want to move all the files we currently have. can do that in a follow-up

if [ "$scope" == "scoped" ]; then
# shellcheck disable=SC2086
JEST_TESTS="$(pnpm exec jest --listTests --json --findRelatedTests $FRONTEND_ALL_FILES | jq '.')"
JEST_TESTS="$(pnpm exec sentry-test --listTests --json --findRelatedTests $FRONTEND_ALL_FILES | jq '.')"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of me thinks we should roll these all up into a vite-plus like CLI eventually...

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b3d6725. Configure here.

Comment thread package.json Resolved
@TkDodo
TkDodo merged commit 2c72ecd into master Oct 15, 2026
78 checks passed
@TkDodo
TkDodo deleted the tkdodo/ref/shared-test-utils branch October 15, 2026 08:15

This branch was successfully deployed

1 active deployment
Preview — b3d6725b Deployed Oct 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants