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

Test logs improvements #17477

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Test logs improvements #17477

wants to merge 4 commits into from

Conversation

jbazant
Copy link
Contributor

@jbazant jbazant commented Mar 7, 2025

Description

Should get rid of some warnings that were bloating our tests pipeline log.

Not ideal solution though.

Related Issue

Resolve

Screenshots:

@jbazant jbazant added the no-project This label is used to specify that PR doesn't need to be added to a project label Mar 7, 2025
@jbazant jbazant requested a review from a team as a code owner March 7, 2025 14:28
coderabbitai[bot]

This comment was marked as outdated.

vytick

This comment was marked as duplicate.

Copy link
Contributor

@vytick vytick left a comment

Choose a reason for hiding this comment

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

Works nicely and that extra logs are gone. Good job 🚀

@trezor-ci trezor-ci force-pushed the test-logs-improvements branch from 81c3a36 to 14fc0fd Compare March 7, 2025 15:04
@trezor trezor deleted a comment from github-actions bot Mar 7, 2025
@trezor trezor deleted a comment from coderabbitai bot Mar 7, 2025
Copy link

github-actions bot commented Mar 7, 2025

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 26
  • More info

Learn more about 𝝠 Expo Github Action

Copy link

coderabbitai bot commented Mar 7, 2025

Walkthrough

The pull request introduces multiple changes across configuration, testing, and module behavior. The Jest configuration is updated to include a new setup script that provides polyfills for the setImmediate and clearImmediate functions on the global window object. In testing utilities, user interactions are now wrapped with the act function to ensure proper state updates during asynchronous events. Documentation has been extended with a new section outlining details related to environment variable warnings in the expo modules, and a patch has been applied to remove outdated development-time checks for the undefined global environment variable process.env.EXPO_OS. Additionally, a module mock has been adjusted to eliminate a previously provided polyfill for setImmediate. No modifications were made to declarations of exported or public entities.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 120a26e and 40db72d.

📒 Files selected for processing (1)
  • packages/suite/src/hooks/wallet/__tests__/useSendForm.test.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: EAS Update
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: build-web
  • GitHub Check: prepare_android_test_app
  • GitHub Check: Setup and Cache Dependencies
🔇 Additional comments (1)
packages/suite/src/hooks/wallet/__tests__/useSendForm.test.tsx (1)

70-70: Good addition - setting default language for tests

Adding the language setting to the preloaded state is a good practice that likely addresses internationalization-related warnings in the test logs. This change ensures that any text or validation messages that depend on the user's language preference will have a consistent default value during tests.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
suite-native/test-utils/src/everstakeJestSetup.js (1)

1-5: Improve setImmediate polyfill to return timeout ID

The setImmediate polyfill should return the timeout ID so it can be properly cleared with clearImmediate.

if (!window.setImmediate) {
    window.setImmediate = function (callback) {
-        setTimeout(callback, 0);
+        return setTimeout(callback, 0);
    };
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13b0b7c and 16b8453.

📒 Files selected for processing (6)
  • jest.config.native.js (1 hunks)
  • packages/suite/src/support/tests/hooksHelper.tsx (2 hunks)
  • patches/README.md (1 hunks)
  • patches/expo-modules-core+2.0.6.patch (1 hunks)
  • suite-native/test-utils/src/everstakeJestSetup.js (1 hunks)
  • suite-native/test-utils/src/expoMock.js (0 hunks)
💤 Files with no reviewable changes (1)
  • suite-native/test-utils/src/expoMock.js
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: prepare_android_test_app
  • GitHub Check: EAS Update
  • GitHub Check: build-web
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: Setup and Cache Dependencies
🔇 Additional comments (5)
jest.config.native.js (1)

32-32: Enhances Jest setup with immediate function polyfills

This addition incorporates the newly created everstakeJestSetup.js file that provides polyfills for setImmediate and clearImmediate functions in the testing environment. A good enhancement to support proper asynchronous testing behavior.

patches/README.md (1)

16-19: Documentation of the expo-modules-core patch is clear and helpful

Good documentation of the patch that's being applied, including references to the relevant GitHub issues. This helps other developers understand why this patch is necessary and what problem it's solving.

patches/expo-modules-core+2.0.6.patch (1)

9-13: Patch successfully removes unnecessary warning

This patch appropriately removes the warning about the undefined process.env.EXPO_OS that was cluttering the test logs. This aligns perfectly with the PR objective of improving test logs by reducing unnecessary warnings.

suite-native/test-utils/src/everstakeJestSetup.js (1)

7-11: clearImmediate polyfill implementation is correct

The clearImmediate polyfill correctly uses clearTimeout to cancel the timer, which works well with the setImmediate implementation using setTimeout.

packages/suite/src/support/tests/hooksHelper.tsx (1)

87-87:

❓ Verification inconclusive

Properly wrapped user interactions with act() to reduce test warnings.

These changes follow React Testing Library best practices by wrapping user interactions with act(), which ensures that all state updates triggered by these interactions are properly processed before the test continues. This will help reduce "Warning: An update to Component inside a test was not wrapped in act(...)" messages in the test logs, aligning with the PR objective of improving test logs.

While these changes are correct, it's worth noting that in recent versions of @testing-library/react, user events are often already wrapped with act() internally. To verify if this double wrapping is necessary in your case:

Also applies to: 95-95, 102-102, 104-104, 108-108


🏁 Script executed:

#!/bin/bash
# Check the version of @testing-library/react and related packages
grep -A 5 "@testing-library/react" package.json || npm list @testing-library/react @testing-library/user-event --depth=0

Length of output: 170


Action Required: Verify Redundant act() Wrapping Based on Dependency Versions

The modifications in packages/suite/src/support/tests/hooksHelper.tsx correctly wrap user interactions within act(), which is aligned with best practices for reducing test warnings. However, since the attempted dependency check for @testing-library/react and @testing-library/user-event did not yield any version information, we cannot conclusively determine whether these user events are already auto-wrapped in your current setup.

Please manually verify that the installed versions of these libraries do not already provide internal act() wrapping. If they do, you might consider removing the explicit act() wrapper in these cases to avoid redundancy. This concern applies to the following lines in the file:

  • 87
  • 95
  • 102
  • 104
  • 108

@jbazant
Copy link
Contributor Author

jbazant commented Mar 7, 2025

/rebase

Copy link

github-actions bot commented Mar 7, 2025

@trezor-ci trezor-ci force-pushed the test-logs-improvements branch from 26b7824 to 120a26e Compare March 7, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-project This label is used to specify that PR doesn't need to be added to a project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants