getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.79k stars 1.53k forks source link

Migrate from jest to vitest and stop using jsdom based tests #11084

Open AbhiPrasad opened 4 months ago

AbhiPrasad commented 4 months ago

After v8 gets merged in, let's look at migrating from jest to vitest. vitest is way faster, and doesn't fall into the same traps jest does in terms of esm compatibility. Example attempt with Vue SDK: https://github.com/getsentry/sentry-javascript/pull/11071

In addition, we should stop using jsdom based tests, and instead move tests that rely on the browser to use playwright instead. Simulating jsdom in an node environment always has it's faults, easier to not attempt to do that.

First we should align on a common vitest testing standard. Right now we use set globals via vitest/globals, but this is not recommended by vitest themselves. We should instead use direct imports like import { describe, test, expect } from 'vitest';.

https://github.com/getsentry/sentry-javascript/blob/780875fd9d13ef6be5f7f894b97c48777022f5e9/tsconfig.dev.json#L8

There's probably some other discussion that needs to be done here too. We can validate our decisions by changing our vitest usage in the Astro and SvelteKit SDKs.

### Update existing vitest usage
- [ ] Astro SDK
- [ ] Nest.js SDK
- [ ] Nuxt SDK
- [ ] https://github.com/getsentry/sentry-javascript/pull/13028
- [ ] SolidStart SDK
- [ ] https://github.com/getsentry/sentry-javascript/pull/13026
- [ ] https://github.com/getsentry/sentry-javascript/pull/12960
- [ ] https://github.com/getsentry/sentry-javascript/pull/13027

We can then tackle the following list in whatever order we want!

### Convert to using vitest
- [x] Angular https://github.com/getsentry/sentry-javascript/pull/11091
- [ ] AWS Serverless
- [ ] Browser
- [ ] Browser Utils
- [ ] Core
- [ ] Feedback
- [ ] Gatsby
- [ ] Google Cloud Serverless
- [ ] Next.js
- [ ] Node
- [ ] OpenTelemetry
- [ ] Profiling Node
- [ ] React
- [ ] Remix
- [ ] https://github.com/getsentry/sentry-javascript/pull/12964
- [ ] https://github.com/getsentry/sentry-javascript/pull/11899
- [ ] https://github.com/getsentry/sentry-javascript/pull/12961
- [ ] Utils - first attempt: https://github.com/getsentry/sentry-javascript/pull/12959
- [ ] https://github.com/getsentry/sentry-javascript/pull/12958
- [ ] https://github.com/getsentry/sentry-javascript/pull/12955
- [x] Wasm
- [ ] Node Integration Tests

We also have some packages that use mocha. We should try to drop that dependency and make them use vitest

### Remove mocha
- [ ] https://github.com/getsentry/sentry-javascript/pull/11296
- [ ] https://github.com/getsentry/sentry-javascript/pull/11412
- [ ] https://github.com/getsentry/sentry-javascript/pull/11436
- [ ] https://github.com/getsentry/sentry-javascript/pull/11449
- [ ] https://github.com/getsentry/sentry-javascript/pull/11666
- [ ] https://github.com/getsentry/sentry-javascript/pull/11688
- [ ] https://github.com/getsentry/sentry-javascript/pull/11733
- [ ] https://github.com/getsentry/sentry-javascript/pull/11758
AbhiPrasad commented 4 months ago

ref https://github.com/getsentry/sentry-javascript/issues/6040

s1gr1d commented 4 months ago

vistest was already added to Angular here: https://github.com/getsentry/sentry-javascript/pull/11091 I will check it on the list 👍🏻

billyvg commented 1 week ago

@AbhiPrasad Replay was migrated here: https://github.com/getsentry/sentry-javascript/pull/11899

edit though we are using globals and not importing everything from vitest