Skip to content

Commit

Permalink
chore: setup the environment
Browse files Browse the repository at this point in the history
Setup the environment for testing and to leverage a component library
for expedience of building the site. It should, also, be noted that MUI
can only be used when a component is rendered client-side, instead of,
the prefered server-side. This is issue accures as of Next.js 13, and is
explained in further detail:
mui/material-ui#34898, mui/material-ui#37315
  • Loading branch information
coulgreer committed May 23, 2023
1 parent 156dc8a commit 91d27dc
Show file tree
Hide file tree
Showing 21 changed files with 16,601 additions and 18 deletions.
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"next",
"plugin:prettier/recommended" //Should always go last
],
"parser": "@typescript-eslint/parser",
"root": true
}
53 changes: 37 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,react
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,react
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

### react ###
.DS_*
*.log
logs
**/*.backup.*
**/*.back.*
# dependencies
/node_modules
/.pnp
.pnp.js

node_modules
bower_components
# testing
/coverage

*.sublime*
# next.js
/.next/
/out/

psd
thumb
sketch
# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# cypress
/cypress/results/*
/cypress/reports/*
/cypress/screenshots/*
/cypress/videos/*

### VisualStudioCode ###
.vscode/*
Expand All @@ -35,5 +58,3 @@ sketch
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,react
58 changes: 58 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# cypress
/cypress/screenshots
/cypress/videos

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
# coulgreer.me
Personal website
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
18 changes: 18 additions & 0 deletions __tests__/app.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import Home from "../src/app/page";
import "@testing-library/jest-dom";

describe("Home", () => {
it("renders a heading", () => {
render(<Home />);

const nav = screen.getByRole("navigation");
const heading = screen.getByRole("heading", {
name: /welcome to next\.js!/i,
});

expect(nav).toBeInTheDocument();
expect(heading).toBeInTheDocument();
});
});
10 changes: 10 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
15 changes: 15 additions & 0 deletions cypress/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe("Navigation", () => {
it("should navigate to the about page", () => {
// Start from the index page
cy.visit("/");

// Find a link with an href attribute containing "about" and click it
cy.get('a[href*="about"]').click();

// The new url should include "/about"
cy.url().should("include", "/about");

// The new page should contain an h1 with "About page"
cy.get("h1").contains("About Page");
});
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
20 changes: 20 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
11 changes: 11 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"noEmit": true
},
"include": [
"../node_modules/cypress",
"**/*.ts"
]
}
13 changes: 13 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import nextJest from 'next/jest.js';

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

const config = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testEnvironment: 'jest-environment-jsdom',
};

export default createJestConfig(config);
1 change: 1 addition & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom/extend-expect';
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}

module.exports = nextConfig

0 comments on commit 91d27dc

Please sign in to comment.