Skip to content
Open
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
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ module.exports = {
node: true,
es6: true,
},
extends: ['eslint:recommended', 'plugin:prettier/recommended', 'next', 'next/core-web-vitals'],
extends: [
'eslint:recommended',
'plugin:prettier/recommended',
'next',
'next/core-web-vitals',
'plugin:cypress/recommended',
],
rules: {
'prettier/prettier': 'error',
'react/react-in-jsx-scope': 'off',
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: E2E tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run
uses: cypress-io/github-action@v5
with:
build: npm run build
start: npm start
12 changes: 12 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
env: {
NODE_ENV: 'development',
},
},
})
5 changes: 5 additions & 0 deletions cypress/e2e/App.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('template spec', () => {
it('passes', () => {
cy.visit('http://localhost:3000')
})
})
45 changes: 45 additions & 0 deletions cypress/e2e/Navigation.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
describe('Navigation', () => {
it('visiting about renders the page successfully', () => {
cy.visit('http://localhost:3000')

cy.get('a[href*="about"]').first().click()

cy.url().should('include', '/about')

cy.get('h1').contains('About')
cy.get('h3').contains('Liam Sorsby')
cy.get('div').contains('Principal Site Reliability Engineer')
})

it('visiting blog renders the page successfully', () => {
cy.visit('http://localhost:3000')

cy.get('a[href*="blog"]').first().click()

cy.url().should('include', '/blog')

cy.get('h1').contains('All Posts')
})

it('visiting tags renders the page successfully', () => {
cy.visit('http://localhost:3000')

cy.get('a[href*="tags"]').first().click()

cy.url().should('include', '/tags')

cy.get('h1').contains('Tags')
})

it('visiting Projects renders the page successfully', () => {
cy.visit('http://localhost:3000')

cy.get('a[href*="projects"]').first().click()

cy.url().should('include', '/projects')

cy.get('h1').contains('Projects')
cy.get('h2').contains('Website')
cy.get('h2').contains('Infrastructure As Code (IoC)')
})
})
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"
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js 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) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.js 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')
9 changes: 9 additions & 0 deletions layouts/PostLayout.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'
import PostLayout from './PostLayout'

describe('<PostLayout />', () => {
it('renders', () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<PostLayout />)
})
})
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build": "next build && node ./scripts/generate-sitemap",
"serve": "next start",
"test": "exit 0",
"cypress": "cypress open --browser chrome",
"analyze": "cross-env ANALYZE=true next build",
"lint": "next lint --dir pages --dir components --dir lib --dir layouts",
"lint:fix": "next lint --fix --dir pages --dir components --dir lib --dir layouts --dir scripts",
Expand Down Expand Up @@ -52,10 +53,12 @@
"devDependencies": {
"@svgr/webpack": "^6.5.1",
"cross-env": "^7.0.3",
"cypress": "^12.11.0",
"dedent": "^0.7.0",
"eslint": "^7.29.0",
"eslint-config-next": "13.1.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-cypress": "^2.13.3",
"eslint-plugin-prettier": "^3.3.1",
"file-loader": "^6.0.0",
"globby": "11.0.3",
Expand Down
Loading