Skip to content

Commit

Permalink
Prepare test base
Browse files Browse the repository at this point in the history
  • Loading branch information
Parnswir committed May 13, 2022
1 parent 9269ed1 commit 9d64c4c
Show file tree
Hide file tree
Showing 9 changed files with 10,675 additions and 6,130 deletions.
116 changes: 0 additions & 116 deletions __tests__/__snapshots__/snapshot.tsx.snap

This file was deleted.

13 changes: 8 additions & 5 deletions __tests__/index.test.tsx
@@ -1,14 +1,17 @@
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event';
import Home from '@/pages/index'

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

const heading = screen.getByRole('heading', {
name: /welcome to next\.js!/i,
})
const trigger = screen.getByText('Nested Content');

expect(heading).toBeInTheDocument()
expect(screen.queryByText('Tooltip Content')).not.toBeInTheDocument();

await userEvent.hover(trigger);

expect(screen.getByText('Tooltip Content')).toBeInTheDocument();
})
})
7 changes: 0 additions & 7 deletions __tests__/snapshot.tsx

This file was deleted.

19 changes: 10 additions & 9 deletions jest.config.js
@@ -1,21 +1,22 @@
const nextJest = require('next/jest')
const nextJest = require("next/jest");

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})
dir: "./",
});

// Add any custom config to be passed to Jest
const customJestConfig = {
testPathIgnorePatterns: ["<rootDir>/.next/", "<rootDir>/node_modules/"],
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
modulePaths: ["<rootDir>"],
moduleNameMapper: {
// Handle module aliases (this will be automatically configured for you soon)
'^@/components/(.*)$': '<rootDir>/components/$1',
"^@/components/(.*)$": "<rootDir>/components/$1",

'^@/pages/(.*)$': '<rootDir>/pages/$1',
"^@/pages/(.*)$": "<rootDir>/pages/$1",
},
testEnvironment: 'jest-environment-jsdom',
}
testEnvironment: "jest-environment-jsdom",
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)
module.exports = createJestConfig(customJestConfig);

0 comments on commit 9d64c4c

Please sign in to comment.