Photo by Yosuke Ota on Unsplash

npm install typescript @types/react @types/node -D
npm i jest @testing-library/react @types/jest babel-jest @testing-library/jest-dom @testing-library/user-event @testing-library/dom -D

Add to package.json:

"test": "jest --watch"

Add to .eslintrc.json:

{
"env": {
"jest": true
}
}

Add to .babelrc:

{
"presets": ["next/babel"]
}

Create jest.config.js

jest.config.js
module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
};

Create jest.setup.ts

jest.setup.ts
import '@testing-library/jest-dom';

Search articles

Type a word to search published articles.

Open the search page