Skip to content

Vitestの設定 #19

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 8 commits into from
Mar 9, 2025
Merged

Vitestの設定 #19

merged 8 commits into from
Mar 9, 2025

Conversation

XeicuLy
Copy link
Owner

@XeicuLy XeicuLy commented Mar 9, 2025

close #5

Summary by CodeRabbit

  • 新機能

    • 開発体験を向上させるため、テストツールとユーティリティの統合が実施され、環境構築が強化されました。
  • テスト

    • テスト実行時の一貫性や品質を確保するため、新たなルールと設定が追加され、より堅牢なテスト環境が実現されています。

@XeicuLy XeicuLy self-assigned this Mar 9, 2025
Copy link

coderabbitai bot commented Mar 9, 2025

"""

Walkthrough

このプルリクエストでは、Vitest テストフレームワークの統合が行われ、ESLint の設定に Vitest 用の新しい構成ブロックが追加されました。また、Nuxt の設定にテストユーティリティ用のモジュールが追加され、関連する新たな開発依存パッケージが package.json に含まれるようになりました。さらに、テスト環境の設定用に新しい vitest.config.ts ファイルが導入され、Nuxt アプリケーションに適したテスト環境が定義されています。

Changes

ファイル 変更の内容
eslint.config.mjs Vitest プラグインのインポートと、**/__test__/**, **/__tests__/**, **/tests/**, **/test/** 対象の新規設定ブロック追加。具体的な Vitest のルール設定を含む。
nuxt.config.ts modules 配列に @nuxt/test-utils/module を追加し、テスト用ユーティリティを統合。
package.json 開発依存パッケージとして、@nuxt/test-utils, @vitest/eslint-plugin, @vitest/ui, @vue/test-utils, happy-dom, vitest が新たに追加。
vitest.config.ts defineVitestConfig を利用した新規テスト設定ファイルの作成。テスト環境を 'nuxt'、happy-dom を使用するように設定し、verbose レポーターを採用。

Sequence Diagram(s)

sequenceDiagram
    participant Dev as 開発者
    participant ESL as ESLint設定
    participant VT as Vitestルール
    participant Nuxt as Nuxtテストモジュール
    participant Config as vitest.config.ts

    Dev->>ESL: コード検査開始
    ESL->>VT: Vitest専用のルール適用
    Dev->>Nuxt: テスト実行依頼
    Nuxt->>Config: テスト環境設定読み込み
    Config-->>Nuxt: テスト環境 (nuxt & happy-dom) を適用
Loading

Possibly related PRs

  • ESLintを設定する #17: ESLint 設定へのVitestルールの統合と CI ワークフローの変更に関連するコードレベルの変更を含んでいます。

Suggested labels

開発環境

Poem

ぴょんぴょん跳ねるうさぎが告げるよ
新たなルールでコードは輝く
Vitestの風が舞い降り
Nuxtの空に希望咲く
うさぎの夢が今日も始まる 🐰✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 794b8f8 and 382fb73.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json (2 hunks)
🔇 Additional comments (2)
package.json (2)

15-18: Vitestのテストスクリプトの追加について
"test": "vitest", "test:ui": "vitest --ui", "test:jsdom": "vitest --ui --environment=jsdom", および "ci:vitest": "vitest --coverage" という新しいスクリプトが追加されています。これにより、テスト実行、UIモードでのテスト、さらにはjsdom環境でのテストが簡単に行えるようになっており、意図されたテスト環境の強化が適切に実装されています。


33-33: Vitestおよび関連テスト依存パッケージの追加について
devDependenciesセクションに、@nuxt/test-utils, @vitest/coverage-v8, @vitest/eslint-plugin, @vitest/ui, @vue/test-utils, happy-dom, jsdom, vitest が追加されています。これらのパッケージは、Nuxt と Vitest のテスト環境を適切にサポートするために必要な依存関係であり、バージョンも明示的に指定されているため、今後の管理もしやすい実装となっています。既存のレビューコメントと内容が重複しますが、追加された依存パッケージに問題はありません。

Also applies to: 36-36, 37-37, 38-38, 40-40, 46-46, 48-48, 52-52


🪧 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 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.

@coderabbitai coderabbitai bot added the 開発環境 開発環境の構築に関連する label Mar 9, 2025
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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 71401af and 794b8f8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • eslint.config.mjs (2 hunks)
  • nuxt.config.ts (1 hunks)
  • package.json (1 hunks)
  • vitest.config.ts (1 hunks)
🔇 Additional comments (4)
nuxt.config.ts (1)

5-5: テストユーティリティモジュールの追加が適切です!

@nuxt/test-utils/module をモジュール配列に追加することで、Nuxtアプリケーションにテスト機能を統合しています。これはVitestでテストを行うための重要な設定です。

vitest.config.ts (1)

1-13: Vitestの設定が適切に構成されています

Nuxtアプリケーション用のVitest設定が適切に構成されています:

  • environment: 'nuxt' でNuxt環境でのテストを有効化
  • reporters: ['verbose'] で詳細なテスト結果の出力を設定
  • happy-dom をDOMテスト環境として適切に設定

これらの設定により、Nuxtアプリケーションのテストが効率的に実行できるようになります。

eslint.config.mjs (2)

7-7: Vitestプラグインの適切なインポート

ESLint設定にVitestプラグインが正しくインポートされています。


88-108: テストファイル用のESLint設定が充実しています

テストディレクトリ向けのESLint設定が適切に構成されています:

  • テスト関数の一貫した命名規則を強制する設定
  • 条件付きテストや期待値の防止
  • 無効化されたテストの禁止
  • 重複したフックの禁止
  • 重複したテストタイトルの防止
  • テストでの戻り値の禁止
  • その他多くのテスト品質向上のためのルール

これらのルールにより、テストコードの品質と一貫性が確保されます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
開発環境 開発環境の構築に関連する
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vitestを追加する
1 participant