Skip to content
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

chore: update test deps #1782

Merged
merged 2 commits into from
Aug 13, 2024
Merged

chore: update test deps #1782

merged 2 commits into from
Aug 13, 2024

Conversation

ripecosta
Copy link
Contributor

### Description

Update all test related dependencies possible at this stage. See comments for more info.

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included
  • commit message and code follows the Developer's Certification of Origin

@adrai adrai requested a review from marcalexiei August 12, 2024 21:47
@coveralls
Copy link

coveralls commented Aug 12, 2024

Coverage Status

coverage: 97.094% (-0.08%) from 97.17%
when pulling 56395fb on ripecosta:rc/update-tests
into 8a1ebc8 on i18next:master.

"@types/react": "^18.2.52",
"@vitest/coverage-v8": "^1.2.2",
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/react": "^12.1.5",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@testing-library/react v13 drop support for react v17 and below so can't upgrade further unless this project also projects support for react v16.

"babel-plugin-macros": "^2.8.0",
"babel-plugin-tester": "^6.5.0",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-tester": "^7.0.4",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating babel-plugin-preset produces a lot of snapshot changes because of how it formats them so it's best done in a separate PR.

"@testing-library/jest-dom": "^6.4.8",
"@testing-library/react": "^12.1.5",
"@testing-library/react-hooks": "^8.0.1",
"@types/jest": "^29.5.12",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@testing-library/jest-dom v6 no longer has @types/jest as its dependency so we need to import it explicitly now.

import { expect } from 'vitest';

expect.extend(matchers);
import '@testing-library/jest-dom/vitest';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -126,7 +126,6 @@ describe('<Trans />', () => {
it('should not work with object child', () => {
assertType<React.ReactElement>(
<Trans>
{/* @ts-expect-error */}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer necessary after downgrading @types/react to v16.

Copy link
Member

Choose a reason for hiding this comment

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

This assertion is necessary since the test checks that an error is thrown when there are object inside child computations and allowObjectInHTMLChildren is disabled.

Check the line below:

<span>This {{ var: '' }} is an error since `allowObjectInHTMLChildren` is disabled</span>

Probably that wasn't an issue with old react types.
This is another reason to update react version rather than downgrading @types/react

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted the @types/react downgrade since we decided to upgrade react instead.

package.json Outdated
"@testing-library/react": "^12.1.5",
"@testing-library/react-hooks": "^8.0.1",
"@types/jest": "^29.5.12",
"@types/react": "^16.14.60",
Copy link
Contributor Author

@ripecosta ripecosta Aug 12, 2024

Choose a reason for hiding this comment

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

Downgrade @types/react to v16 was necessary because of @testing-library/react-hooks v8. Regardless, it makes sense to use v16 instead of v18 because that's this repo is using react v16 to test.

@@ -116,7 +117,7 @@
"rimraf": "^6.0.1",
"rollup": "^4.20.0",
"typescript": "~5.5.4",
"vitest": "1.2.2",
"vitest": "^2.0.5",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

vitest v2 (changelog) enables coverage.ignoreEmptyLines by default so coverage is expected to drop slightly in some files

Copy link
Member

@marcalexiei marcalexiei left a comment

Choose a reason for hiding this comment

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

IMHO I think it would be better if react and @types/react have a more recent version, I would go with v18.
This means that we can use more recent version of other test dependencies, as stated in @ripecosta's comments.

What do you think @adrai?

@adrai
Copy link
Member

adrai commented Aug 13, 2024

IMHO I think it would be better if react and @types/react have a more recent version, I would go with v18.

This means that we can use more recent version of other test dependencies, as stated in @ripecosta's comments.

What do you think @adrai?

Yes, we can update to v18

@ripecosta
Copy link
Contributor Author

ripecosta commented Aug 13, 2024

Sounds good @adrai @marcalexiei. In that case for this PR I'll keep @testing-library/react-hooks at v7 so we can upgrade react in it's own PR. I will require releasing a new major version too so it's another reason to keep it separate.

Copy link

Report too large to display inline

View full report↗︎

Copy link

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Install scripts npm/[email protected]
  • Install script: install
  • Source: node install.js
🚫

View full report↗︎

Next steps

What is an install script?

Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.

Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

@adrai adrai merged commit 35b4821 into i18next:master Aug 13, 2024
8 of 9 checks passed
@ripecosta ripecosta deleted the rc/update-tests branch August 13, 2024 10:06
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.

4 participants