├── .eslintrc.json ├── .gitignore ├── LICENSE ├── README.md ├── components ├── button │ ├── index.tsx │ ├── style.module.scss │ └── tests │ │ └── index.unit.spec.tsx └── readme.md ├── jest.config.js ├── next-env.d.ts ├── next.config.js ├── package-lock.json ├── package.json ├── pages ├── _app.js ├── _document.js ├── example │ └── example.tsx └── index.tsx ├── public ├── favicon.ico └── zeit.svg ├── setupTests.ts ├── theme └── index.ts ├── tsconfig.jest.json └── tsconfig.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true 6 | }, 7 | "extends": [ 8 | "plugin:react/recommended", 9 | "plugin:prettier/recommended", 10 | "plugin:@typescript-eslint/eslint-recommended", 11 | "plugin:@typescript-eslint/recommended", 12 | "plugin:jest/all", 13 | "standard", 14 | "prettier" 15 | ], 16 | "globals": { 17 | "Atomics": "readonly", 18 | "SharedArrayBuffer": "readonly" 19 | }, 20 | "parser": "@typescript-eslint/parser", 21 | "parserOptions": { 22 | "ecmaFeatures": { 23 | "jsx": true 24 | }, 25 | "ecmaVersion": 2018, 26 | "sourceType": "module" 27 | }, 28 | "settings": { 29 | "react": { 30 | "version": "detect" 31 | } 32 | }, 33 | "plugins": [ 34 | "react", 35 | "@typescript-eslint" 36 | ], 37 | "rules": { 38 | "prettier/prettier": "error", 39 | "jest/no-hooks": "off", 40 | "jest/prefer-expect-assertions": "off", 41 | "jest/no-standalone-expect": "off", 42 | "react/prop-types": 0, 43 | "jest/expect-expect": [ 44 | "warn", 45 | { 46 | "assertFunctionNames": [ 47 | "expect", 48 | "request.*.expect" 49 | ] 50 | } 51 | ], 52 | "jest/lowercase-name": "off", 53 | "@typescript-eslint/no-empty-function": "warn", 54 | "camelcase": "warn", 55 | "no-case-declarations": "warn", 56 | "no-use-before-define": "off", 57 | "@typescript-eslint/no-use-before-define": [ 58 | "error" 59 | ], 60 | "@typescript-eslint/explicit-module-boundary-types": "off" 61 | } 62 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | .env* 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mehmet Sefa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## NEXTJS STARTER TEMPLATE WITH TYPESCRIPT, MATERIALUI AND JEST 2 | 3 | This is a Nextjs project whose Typescript, MaterialUI and Jest config setups are made by default. 4 | 5 | If you want to kickstart a project using Nextjs, Typescript, MaterialUI and Jest, clone this already-setup-repo and start coding! 6 | 7 | ``` 8 | npm i 9 | ``` 10 | 11 | ``` 12 | npm run test 13 | ``` 14 | 15 | ``` 16 | npm run dev 17 | ``` 18 | -------------------------------------------------------------------------------- /components/button/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { FunctionComponent } from "react"; 2 | import MuiButton from "@mui/material/Button"; 3 | import style from "./style.module.scss"; 4 | 5 | interface Props { 6 | color: "primary" | "secondary"; 7 | name: string; 8 | } 9 | 10 | const Button: FunctionComponent = ({ color, name }) => { 11 | return ( 12 | <> 13 | 14 | {name} 15 | 16 |
pink text
17 | 18 | ); 19 | }; 20 | export { Button }; 21 | -------------------------------------------------------------------------------- /components/button/style.module.scss: -------------------------------------------------------------------------------- 1 | .text { 2 | color: pink; 3 | } -------------------------------------------------------------------------------- /components/button/tests/index.unit.spec.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import sinon, { SinonStub } from "sinon"; 3 | import faker from "faker"; 4 | import { render, cleanup } from "@testing-library/react"; 5 | import { Button } from "../index"; 6 | import { ThemeProvider } from "@material-ui/core/styles"; 7 | import { theme } from "../../../theme"; 8 | import MuiButton from "@material-ui/core/Button"; 9 | 10 | const sandbox = sinon.createSandbox(); 11 | const { 12 | lorem: { word }, 13 | } = faker; 14 | 15 | describe("Button Unit Tests", () => { 16 | afterEach(() => { 17 | sandbox.verifyAndRestore(); 18 | cleanup(); 19 | }); 20 | 21 | it("should render", () => { 22 | // Arrange 23 | sandbox.spy(React, "createElement"); 24 | 25 | // Act 26 | const { container } = render( 27 | 28 |