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: add commands to run tests and storybook in StrictMode #3352

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

chirokas
Copy link
Contributor

@chirokas chirokas commented Jun 28, 2024

Closes #

📝 Description

Developing in strict mode is the best practice for React because it helps teams catch bugs earlier.

⛳️ Current behavior (updates)

Please describe the current behavior that you are modifying

🚀 New behavior

Please describe the behavior or changes this PR adds

💣 Is this a breaking change (Yes/No):

📝 Additional Information

Summary by CodeRabbit

  • New Features
    • Introduced strict mode options for development and testing environments.
  • Chores
    • Added new scripts for strict development and testing.
    • Updated and reorganized package dependencies.
  • Configuration
    • Enhanced Storybook configuration with strict mode options and improved formatting.

Copy link

changeset-bot bot commented Jun 28, 2024

⚠️ No Changeset found

Latest commit: 3441b65

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jun 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 28, 2024 1:45pm

Copy link

vercel bot commented Jun 28, 2024

@chirokas is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jun 28, 2024

Walkthrough

The updates introduce stricter mode options for both development and testing environments through new scripts in the package.json and configuration changes in Storybook and testing setup. Key dependencies were added and updated to support these changes. The goal is to ensure more rigorous code quality checks during development and testing phases.

Changes

File Change Summary
package.json Added dev:strict and test:strict scripts. Added @storybook/react and cross-env to dev dependencies. Moved tsx to dependencies. Updated various packages.
packages/storybook/.storybook/main.js Added strictMode option to the framework section. Added trailing comma after disableTelemetry.
scripts/setup-test.ts Imported configure from @testing-library/react. Added reactStrictMode config based on process.env.STRICT_MODE.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
Contributor

@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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 78d4216 and 3441b65.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (3)
  • package.json (7 hunks)
  • packages/storybook/.storybook/main.js (1 hunks)
  • scripts/setup-test.ts (2 hunks)
Additional comments not posted (6)
packages/storybook/.storybook/main.js (2)

23-23: Stylistic Improvement: Trailing Comma Added

Adding a trailing comma after disableTelemetry is a good practice for cleaner diffs in version control systems.


18-20: Implementation of Strict Mode in Storybook looks correct.

The use of process.env.STRICT_MODE === "true" ensures that strict mode is only enabled when explicitly specified. This is a good practice to avoid unintentional activation.

Verification successful

Implementation of Strict Mode in Storybook looks correct.

The use of process.env.STRICT_MODE === "true" ensures that strict mode is only enabled when explicitly specified. This is a good practice to avoid unintentional activation. The environment variable STRICT_MODE was correctly set to 'true' during the simulated run.

  • The environment variable STRICT_MODE is properly set and utilized.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that STRICT_MODE environment variable is properly set when running Storybook.

# Test: Check the environment variable during Storybook run.
echo "Ensure that the STRICT_MODE environment variable is set to 'true' or 'false' as expected when running Storybook."

Length of output: 246



Script:

#!/bin/bash
# Description: Verify that STRICT_MODE environment variable is properly set and utilized during Storybook run.

# Test: Check the environment variable during Storybook run.
# We will simulate running Storybook and print the value of STRICT_MODE.
# Note: This is a simulation and not the actual run of Storybook.

# Set the environment variable for testing
export STRICT_MODE="true"

# Simulate running Storybook and check the environment variable
node -e 'console.log("STRICT_MODE:", process.env.STRICT_MODE);'

Length of output: 183



Script:

#!/bin/bash
# Description: Verify that STRICT_MODE environment variable is properly set and utilized during Storybook run.

# Test: Check the environment variable during Storybook run.
# We will simulate running Storybook and print the value of STRICT_MODE.
# Note: This is a simulation and not the actual run of Storybook.

# Set the environment variable for testing
export STRICT_MODE="true"

# Simulate running Storybook and check the environment variable
echo "STRICT_MODE: $STRICT_MODE"

Length of output: 89

scripts/setup-test.ts (2)

2-2: Correct Import for Test Configuration

The import of configure from @testing-library/react is necessary for setting up the test environment. Ensure that it is used effectively in the rest of the file.

Verification successful

Correct Import and Usage of configure

The import of configure from @testing-library/react is correctly implemented and used in scripts/setup-test.ts.

  • Line 2: import { configure } from "@testing-library/react";
  • Usage: configure({ ... });
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `configure` in test setups.

# Test: Search for `configure` usage in the file.
rg --type ts "configure" ./scripts/setup-test.ts

Length of output: 112


34-36: Proper Configuration of Strict Mode in Tests

Setting reactStrictMode based on the STRICT_MODE environment variable is a robust way to conditionally enable strict mode for tests.

Verification successful

Proper Configuration of Strict Mode in Tests

Setting reactStrictMode based on the STRICT_MODE environment variable is a robust way to conditionally enable strict mode for tests. The STRICT_MODE environment variable is properly set in the package.json file for the relevant scripts.

  • package.json:
    • "dev:strict": "cross-env STRICT_MODE=true pnpm dev"
    • "test:strict": "cross-env STRICT_MODE=true pnpm test"
  • scripts/setup-test.ts:
    • reactStrictMode: process.env.STRICT_MODE === "true"
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that STRICT_MODE environment variable is properly set when running tests.

# Test: Check the environment variable during test runs.
echo "Ensure that the STRICT_MODE environment variable is set to 'true' or 'false' as expected when running tests."

Length of output: 238



Script:

#!/bin/bash
# Description: Verify that the STRICT_MODE environment variable is properly set when running tests.

# Test: Check the value of the STRICT_MODE environment variable.
# We will print the value of STRICT_MODE to ensure it is being set correctly.

echo "STRICT_MODE is set to: $STRICT_MODE"

# Additionally, we can list all environment variables to see if STRICT_MODE is present
printenv | grep STRICT_MODE

Length of output: 163



Script:

#!/bin/bash
# Description: Search for any occurrences of the STRICT_MODE environment variable in the codebase.

# Search for STRICT_MODE in the codebase to verify its usage and setting.
rg --fixed-strings "STRICT_MODE"

Length of output: 251

package.json (2)

16-16: New Scripts for Strict Mode Execution

The addition of dev:strict and test:strict scripts using cross-env to set the STRICT_MODE environment variable is a practical approach to enable strict mode. Ensure to test these scripts to verify they function as intended.

Also applies to: 29-29


Line range hint 73-93: Dependency Updates Reviewed

Updates to dependencies like @storybook/react, concurrently, and cross-env are important for maintaining project health. Verify that these updates do not introduce compatibility issues with existing code.

Also applies to: 118-118, 123-136

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.

None yet

1 participant