Skip to content

Commit

Permalink
Move to Vitest from Jest
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Dec 19, 2024
1 parent 9021d72 commit 5dd82c4
Show file tree
Hide file tree
Showing 6 changed files with 1,402 additions and 2,337 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ jobs:
- name: Create mock config.json
run: echo '{"ip":"http://localhost:42069"}' > config.json

- name: Run linter
- name: Run linter and TypeScript checks
run: yarn lint

# - name: Run tests
# run: yarn test --ci

# - name: Build app (not sure we should do this)
# run: yarn build
- name: Run tests
run: yarn test
19 changes: 6 additions & 13 deletions __tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import React from 'react'
import { expect, test } from 'vitest'
import { render, screen } from '@testing-library/react'
import Home from '../pages/index'
import '@testing-library/jest-dom'

jest.mock('next/router', () => require('next-router-mock'))
jest.mock('next/dist/client/router', () => require('next-router-mock'))

describe('Home', () => {
it('renders a heading', () => {
render(<Home />)

const heading = screen.getByRole('heading', {
name: /Octyne/i
})

expect(heading).toBeInTheDocument()
test('renders a heading', () => {
render(<Home />)
const heading = screen.getByRole('heading', {
name: /Octyne/i
})
expect(heading).toBeDefined()
})
19 changes: 0 additions & 19 deletions jest.config.js

This file was deleted.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"private": true,
"packageManager": "yarn@4.5.3",
"scripts": {
"test": "jest",
"test": "vitest",
"dev": "next",
"build": "next build",
"start": "next start",
Expand All @@ -36,15 +36,14 @@
"@babel/core": "^7.26.0",
"@next/eslint-plugin-next": "^15.1.2",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.2",
"@types/react": "^19.0.2",
"@types/react-virtualized-auto-sizer": "^1.0.4",
"@types/react-window": "^1.8.8",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.17.0",
"eslint-config-love": "^112.0.0",
"eslint-config-standard-jsx": "^11.0.0",
Expand All @@ -55,9 +54,11 @@
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.1.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^25.0.1",
"next-router-mock": "^0.9.13",
"typescript": "^5.7.2"
"typescript": "^5.7.2",
"vite": "^6.0.4",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^2.1.8"
}
}
11 changes: 11 additions & 0 deletions vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
plugins: [tsconfigPaths(), react()],
test: {
environment: 'jsdom',
alias: { 'next/router': 'next-router-mock' },
},
})
Loading

0 comments on commit 5dd82c4

Please sign in to comment.