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: Jest→Vitestへの移行 #21

Merged
merged 1 commit into from Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5,139 changes: 3,429 additions & 1,710 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions package.json
Expand Up @@ -7,8 +7,8 @@
"build": "next build",
"start": "next start",
"lint": "next lint --dir src",
"test": "jest --watch",
"test:all": "jest --watchAll=false --coverage",
"test": "vitest",
"test:all": "vitest run --coverage",
"format": "prettier --write --ignore-path .gitignore './**/*.{js,jsx,ts,tsx,json}'"
},
"dependencies": {
Expand All @@ -29,12 +29,16 @@
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@vitejs/plugin-react": "^4.0.2",
"@vitest/coverage-v8": "^0.33.0",
"autoprefixer": "^10.4.14",
"eslint-config-prettier": "^8.8.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jsdom": "^22.1.0",
"postcss": "^8.4.23",
"prettier": "^2.8.8",
"tailwindcss": "^3.3.2"
"tailwindcss": "^3.3.2",
"vitest": "^0.33.0"
}
}
2 changes: 1 addition & 1 deletion src/Components/__test__/header.test.jsx
@@ -1,6 +1,6 @@
import { render } from '@testing-library/react'
import { expect, test, describe } from 'vitest'
import Header from '../header'
import '@testing-library/jest-dom'

describe('Header部分のテスト', () => {
test('boobyというタイトル文字が表示されているかどうか', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/Components/__test__/pagination.test.tsx
@@ -1,9 +1,9 @@
import { render } from '@testing-library/react'
import '@testing-library/jest-dom'
import Pagination from '../pagination'
import { expect, test, vi } from 'vitest';
import Pagination from '@/Components/pagination'

jest.mock('next/router', () => ({
useRouter: jest.fn().mockReturnValue({
vi.mock('next/router', () => ({
useRouter: vi.fn().mockReturnValue({
pathname: '/',
query: { language: 'javascript' },
}),
Expand Down
2 changes: 1 addition & 1 deletion src/Components/__test__/repositoryCard.test.jsx
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react'
import '@testing-library/jest-dom'
import { expect, test } from 'vitest'
import RepositoryCard from '@/Components/repositoryCard'

const repository = {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/__test__/repositorySearchForm.test.jsx
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react'
import '@testing-library/jest-dom'
import { expect, test } from 'vitest'
import RepositorySearchForm from '@/Components/repositorySearchForm'

describe('RepositSearchFormのテスト', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/Components/__test__/select.test.jsx
@@ -1,6 +1,6 @@
import { render, fireEvent } from '@testing-library/react'
import { render } from '@testing-library/react'
import { expect, test } from 'vitest'
import Select from '@/Components/select'
import '@testing-library/jest-dom'

const options = [
{ label: 'A', value: 'a' },
Expand Down
1 change: 1 addition & 0 deletions src/test/setup.ts
@@ -0,0 +1 @@
import '@testing-library/jest-dom'
17 changes: 17 additions & 0 deletions vitest.config.ts
@@ -0,0 +1,17 @@
/// <reference types="vitest" />
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vitest/config'

export default defineConfig({
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/test/setup.ts',
},
resolve: {
alias: {
'@': __dirname + '/src',
},
},
})