0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Next.jsにvitest入れ、テスト時のエラー回避

Posted at

テスト実行に発生するエラー内容

Error:~~~hogehoge /src/test/setup.ts). Does the file exist?

srcディレクトリ配下にtestディレクトリを作成してsetup.tsがないと言われている。早速、作成してみる。

解決策

import '@testing-library/jest-dom';

上記を記述。早速、こちらでエラー回避することができました。

実行

    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "test": "vitest watch",
    "coverage": "vitest run --coverage",
    "lint": "eslint src",
    "lint:fix": "eslint src --fix",
    "format": "prettier . --write",
    "prepare": "husky install"
pnpm test
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?