Skip to content

Setting up implementation for Next JS Testing using JEST

Notifications You must be signed in to change notification settings

iamawaisakram/testing-with-nextjs

Repository files navigation

Getting Started

Dependencies Installed:

jest @testing-library/react babel-jest @testing-library/jest-dom @testing-library/user-event @testing-library/dom identity-obj-proxy -D

At Root

touch .babelrc

  • Add in .babelrc
{
  "presets": ["next/babel"]
}

touch jest.config.js

// jest.config.js
module.exports = {
  setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
  testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
  moduleNameMapper: {
    '\\.(scss|sass|css)$': 'identity-obj-proxy',
  },
};

touch jest.setup.js

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

package.json

"scripts": {
    ...,
    "test": "jest"
  },

First, run the development server:

npm run dev
# or
yarn dev

About

Setting up implementation for Next JS Testing using JEST

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published