Skip to content

fix(tests): Fix type errors in tests #4908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 14, 2022
Merged

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Apr 11, 2022

In the process of updating our jest dependencies, a significant number of type errors in tests suddenly appeared. (It seems newer versions of jest et al are stricter than the ones we had been using.) This fixes those errors, and changes our jest config so that it will throw an error on any types problems in a test, so we'll know to fix them locally. (Still to do: Fix our configuration so that the linter will catch the errors, so we don't have to actually run the tests to find them.)

@github-actions
Copy link
Contributor

github-actions bot commented Apr 11, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.2 KB (+0.28% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 64.33 KB (-0.44% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.84 KB (-0.09% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 57.94 KB (-0.06% 🔽)
@sentry/browser - Webpack (gzipped + minified) 23.41 KB (+0.76% 🔺)
@sentry/browser - Webpack (minified) 81.21 KB (-0.63% 🔽)
@sentry/react - Webpack (gzipped + minified) 23.46 KB (+0.79% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.96 KB (-0.19% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.04 KB (-0.12% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.42 KB (-0.27% 🔽)

@lobsterkatie lobsterkatie force-pushed the kmclb-fix-test-type-errors branch from 13b8b62 to b5599ed Compare April 11, 2022 07:15
@AbhiPrasad AbhiPrasad added this to the 7.0.0 milestone Apr 11, 2022
@lobsterkatie lobsterkatie force-pushed the kmclb-fix-test-type-errors branch 6 times, most recently from ef459cd to 355b930 Compare April 14, 2022 17:45
@lobsterkatie lobsterkatie force-pushed the kmclb-fix-test-type-errors branch from 355b930 to befc9e3 Compare April 14, 2022 18:52
@lobsterkatie lobsterkatie marked this pull request as ready for review April 14, 2022 19:25
@@ -511,10 +511,10 @@ describe('Scope', () => {
contexts: { bar: { id: '3' }, baz: { id: '4' } },
extra: { bar: '3', baz: '4' },
fingerprint: ['bar'],
level: 'warning',
level: 'warning' as const,
Copy link
Member

Choose a reason for hiding this comment

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

why do we need the const cast? Because of SeverityLevel? Hmm this might make upgrading more tricky for users then right?

Copy link
Member Author

@lobsterkatie lobsterkatie Apr 14, 2022

Choose a reason for hiding this comment

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

Yeah, I had that same thought. And yet, here are just a few of the many examples of other places in the SDK, both in source code and tests, where this wasn't necessary:

image

This PR is basically a collection of all of the fixes I've had to make ever since I started work on upgrading jest, and it's been rebased any number of times - the PRs on which it depends had to work their way though to getting merged, and in the meantime things in the repo have been changing rapidly and I've kept having to add new fixes. So it's possible that that was necessary at some stage along the way and now isn't, maybe? Because I don't see how this instance is different from all of the ones above. I'll try again without.

UPDATE: Ah, that's the difference. Drat.

So, it turns out it is necessary, because of the indirection through the localAttributes variable. If you pass the localAttributes value directly, rather than assigning it and using the variable, you don't need the as const. I guess TS implicitly types localAttributes.level as string (which, actually, is what it should do), and that's all that carries through to the function. 😕

It's not a blocker for this PR, but probably something we should discuss IRL.

@lobsterkatie lobsterkatie merged commit 91f2634 into 7.x Apr 14, 2022
@lobsterkatie lobsterkatie deleted the kmclb-fix-test-type-errors branch April 14, 2022 20:30
Lms24 pushed a commit that referenced this pull request Apr 26, 2022
In the process of updating our jest dependencies, a significant number of type errors in tests suddenly appeared. (It seems newer versions of `jest` et al are stricter than the ones we had been using.) This fixes those errors, and changes our jest config so that it will throw an error on any types problems in a test, so we'll know to fix them locally. (Still to do: Fix our configuration so that the linter will catch the errors, so we don't have to actually run the tests to find them.)
lobsterkatie added a commit that referenced this pull request Apr 26, 2022
In the process of updating our jest dependencies, a significant number of type errors in tests suddenly appeared. (It seems newer versions of `jest` et al are stricter than the ones we had been using.) This fixes those errors, and changes our jest config so that it will throw an error on any types problems in a test, so we'll know to fix them locally. (Still to do: Fix our configuration so that the linter will catch the errors, so we don't have to actually run the tests to find them.)
lobsterkatie added a commit that referenced this pull request Apr 26, 2022
In the process of updating our jest dependencies, a significant number of type errors in tests suddenly appeared. (It seems newer versions of `jest` et al are stricter than the ones we had been using.) This fixes those errors, and changes our jest config so that it will throw an error on any types problems in a test, so we'll know to fix them locally. (Still to do: Fix our configuration so that the linter will catch the errors, so we don't have to actually run the tests to find them.)
AbhiPrasad pushed a commit that referenced this pull request May 30, 2022
In the process of updating our jest dependencies, a significant number of type errors in tests suddenly appeared. (It seems newer versions of `jest` et al are stricter than the ones we had been using.) This fixes those errors, and changes our jest config so that it will throw an error on any types problems in a test, so we'll know to fix them locally. (Still to do: Fix our configuration so that the linter will catch the errors, so we don't have to actually run the tests to find them.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants