Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "next/core-web-vitals",
"rules": {
"@next/next/no-img-element": "off",
"react/no-unescaped-entities": "off"
}
}
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.export = 'test-file-stub';
1 change: 1 addition & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.export = {}
16 changes: 16 additions & 0 deletions __tests__/index.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// __tests__/index.test.jsx

import { render, screen } from "@testing-library/react";
import Index from "../pages/index";

describe("Index", () => {
it("should render the page", () => {
render(<Index />);

const headingArray = screen.getAllByRole("heading");

headingArray.map((heading) => {
expect(heading).toBeInTheDocument();
});
});
});
21 changes: 21 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// jest.config.js
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 : './',
})

// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv : [ '<rootDir>/jest.setup.js' ],
// if using TypeScript with a baseUrl set to the root directory then you need
// the below for alias' to work
moduleDirectories : [ 'node_modules', '<rootDir>/' ],
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)
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom/extend-expect';
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "jest"
},
"dependencies": {
"next": "^12.0.9",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"autoprefixer": "^10.4.2",
"eslint": "8.8.0",
"eslint-config-next": "12.0.9",
"jest": "^27.4.7",
"postcss": "^8.4.5",
"tailwindcss": "^3.0.18"
}
}
7 changes: 7 additions & 0 deletions pages/_app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "../styles/global.css";

function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
}

export default MyApp;
Loading