Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
js-tests: Update some docs related to JS tests (#1121)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan953 authored Jan 8, 2024
1 parent f33d697 commit a70d301
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/docs/frontend/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ We are currently exploring alternatives to the `Reflux` library for future use.
For React Testing Library (RTL) tips check out <Link to="/frontend/using-rtl/">this page</Link>.
</Alert>
Note: Your filename needs to be `.spec.jsx` or `.spec.tsx` for jest to run run it!
Note: Your filename needs to be `.spec.tsx` for jest to run run it!
We have useful fixtures defined in [setup.ts](https://github.com/getsentry/sentry/blob/master/tests/js/setup.ts) Use these! If you are defining mock data in a repetitive way, it’s probably worth adding this this file. routerContext is a particularly useful one for providing the context object that most view are written to rely on.
Expand All @@ -172,11 +172,6 @@ expect(wrapper.find('CommitRow')).toHaveLength(2);
If you are writing jest tests, you can use a Component (and Styled Component) names as a selector. Additionally, if you need to use a DOM query selector, use `data-test-id` instead of a class name. We currently don’t, but it is something we can use babel to strip out during the build process.
### Undefined `theme` properties in tests
Instead of using `mount()` from `enzyme` ...use this: `import {mountWithTheme} from 'sentry-test/enzyme'` so that the component under test gets wrapped with a [`<ThemeProvider>`](https://emotion.sh/docs/theming).
## Babel Syntax Plugins
We have decided to only use ECMAScript proposals that are in stage 3 (or later) (See [TC39 Proposals](https://github.com/tc39/proposals)). Additionally, because we are migrating to typescript, we will align with what their compiler supports.
The only exception to this are decorators.
Expand Down
3 changes: 2 additions & 1 deletion src/docs/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ yarn test tests/js/spec/views/issueList/overview.spec.js
### API Fixtures

Because our Jest tests run without an API we have a variety of fixture builders available to help generate
API response payloads. The `TestStubs` global includes all the fixture functions in `tests/js/sentry-test/fixtures/`.
API response payloads. They are available for import with the alias `sentry-fixture/*`. New fixtures can be created
inside of `sentry/fixtures/js-stubs/`.

You should also use `MockApiClient.addMockResponse()` to set responses for API calls your components will make. Failing
to mock an endpoint will result in tests failing.

1 comment on commit a70d301

@vercel
Copy link

@vercel vercel bot commented on a70d301 Jan 8, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

develop – ./

develop.sentry.dev
develop-git-master.sentry.dev

Please sign in to comment.