-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,062 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,33 @@ jobs: | |
cache: | ||
name: CI cache | ||
runs-on: ubuntu-latest | ||
outputs: | ||
pnpm-cache: ${{ steps.vars.outputs.pnpm-cache }} | ||
key: ${{ steps.vars.outputs.key }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: pnpm/[email protected] | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18.x" | ||
cache: 'pnpm' | ||
- run: pnpm install | ||
- id: vars | ||
run: | | ||
echo "pnpm-cache=$(pnpm store path --silent)" >> $GITHUB_OUTPUT | ||
echo "key=${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT | ||
- name: Cache NPM and Cypress 📦 | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: | | ||
${{ steps.vars.outputs.pnpm-cache }} | ||
~/.cache/Cypress | ||
key: ${{ steps.vars.outputs.key }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} | ||
${{ runner.os }}-pnpm- | ||
- run: pnpm install --frozen-lockfile --prefer-offline | ||
env: | ||
HUSKY: '0' # By default do not run HUSKY install | ||
|
||
lint: | ||
name: lint | ||
|
@@ -30,8 +49,20 @@ jobs: | |
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18.x" | ||
cache: 'pnpm' | ||
- run: pnpm install | ||
- name: Cache NPM and Cypress 📦 | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: | | ||
${{ needs.cache.outputs.pnpm-cache }} | ||
~/.cache/Cypress | ||
key: ${{ needs.cache.outputs.key }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} | ||
${{ runner.os }}-pnpm- | ||
- run: pnpm install --frozen-lockfile --prefer-offline | ||
env: | ||
HUSKY: '0' # By default do not run HUSKY install | ||
- run: pnpm lint:ci | ||
- run: pnpm format:ci | ||
|
||
|
@@ -45,13 +76,32 @@ jobs: | |
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18.x" | ||
cache: 'pnpm' | ||
- run: pnpm install && cd ./examples/webpack && pnpm cypress install | ||
- name: Cache NPM and Cypress 📦 | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: | | ||
${{ needs.cache.outputs.pnpm-cache }} | ||
~/.cache/Cypress | ||
key: ${{ needs.cache.outputs.key }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} | ||
${{ runner.os }}-pnpm- | ||
- run: pnpm install --frozen-lockfile --prefer-offline | ||
env: | ||
HUSKY: '0' # By default do not run HUSKY install | ||
- run: pnpm --filter cypress-plugin-visual-regression-diff -r build | ||
- name: Test e2e | ||
run: pnpm test:e2e:ci | ||
- name: Test component-testing | ||
run: pnpm test:ct:ci | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: test | ||
path: | | ||
examples/next/**/*.png | ||
examples/next/**/*.jpg | ||
examples/next/**/*.jpeg | ||
test-integration-coverage: | ||
name: test-integration-coverage | ||
|
@@ -63,8 +113,20 @@ jobs: | |
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18.x" | ||
cache: 'pnpm' | ||
- run: pnpm install | ||
- name: Cache NPM and Cypress 📦 | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: | | ||
${{ needs.cache.outputs.pnpm-cache }} | ||
~/.cache/Cypress | ||
key: ${{ needs.cache.outputs.key }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} | ||
${{ runner.os }}-pnpm- | ||
- run: pnpm install --frozen-lockfile --prefer-offline | ||
env: | ||
HUSKY: '0' # By default do not run HUSKY install | ||
- name: Test integration (with coverage) and upload to CodeClimate | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
uses: paambaati/[email protected] | ||
|
@@ -100,18 +162,30 @@ jobs: | |
build-and-release: | ||
name: build and release | ||
runs-on: ubuntu-latest | ||
needs: prepare-release | ||
needs: [cache, prepare-release] | ||
if: needs.prepare-release.outputs.releases_created | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: pnpm/[email protected] | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18.x" | ||
cache: 'pnpm' | ||
registry-url: 'https://registry.npmjs.org' | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- run: pnpm install | ||
- name: Cache NPM and Cypress 📦 | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: | | ||
${{ needs.cache.outputs.pnpm-cache }} | ||
~/.cache/Cypress | ||
key: ${{ needs.cache.outputs.key }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} | ||
${{ runner.os }}-pnpm- | ||
- run: pnpm install --frozen-lockfile --prefer-offline | ||
env: | ||
HUSKY: '0' # By default do not run HUSKY install | ||
- name: Build packages to get cross-references working 🔧 | ||
run: pnpm build | ||
- name: Release package | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# we do not want to commit local screenshot files | ||
# as they might be different on different OSes | ||
**/__image_snapshots_local__ | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Next.js + Cypress + @frsource/cypress-plugin-visual-regression-diff | ||
|
||
This example shows how to configure @frsource/cypress-plugin-visual-regression-diff to work with Cypress & Next.js. | ||
|
||
## Project setup | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
### Run end-to-end tests | ||
|
||
> Important - remember to run `pnpm && pnpm build` command in this repo's root directory before starting e2e tests. | ||
```bash | ||
pnpm e2e | ||
``` | ||
|
||
### Run component tests | ||
|
||
> Important - remember to run `pnpm && pnpm build` command in this repo's root directory before starting e2e tests. | ||
```bash | ||
pnpm component | ||
``` | ||
|
||
### Compiles and hot-reloads for development | ||
|
||
```bash | ||
pnpm dev | ||
``` | ||
|
||
### Compiles and minifies for production | ||
|
||
```bash | ||
pnpm build | ||
``` | ||
|
||
## Credits | ||
|
||
Created using [Next.js Cypress template](https://nextjs.org/docs/pages/building-your-application/optimizing/testing#cypress). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import AboutComponent from './about-component' | ||
// Disable ESLint to prevent failing linting inside the Next.js repo. | ||
// If you're using ESLint on your project, we recommend installing the ESLint Cypress plugin instead: | ||
// https://github.com/cypress-io/eslint-plugin-cypress | ||
|
||
describe('<AboutComponent />', () => { | ||
it('should render and display expected content', () => { | ||
cy.mount(<AboutComponent />).then(() => { | ||
cy.matchImage() | ||
cy.get('h1').matchImage() | ||
}) | ||
}) | ||
}) | ||
|
||
// Prevent TypeScript from reading file as legacy script | ||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Link from 'next/link' | ||
import React from 'react' | ||
import styles from '../styles/Home.module.css' | ||
|
||
export default function AboutComponent() { | ||
return ( | ||
<> | ||
<h1>About Page</h1> | ||
<p className={styles.description}> | ||
<Link href="/">← Go Back</Link> | ||
</p> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { defineConfig } from "cypress"; | ||
import { initPlugin } from "@frsource/cypress-plugin-visual-regression-diff/plugins"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
initPlugin(on, config); | ||
}, | ||
baseUrl: "http://localhost:3000", | ||
}, | ||
component: { | ||
setupNodeEvents(on, config) { | ||
initPlugin(on, config); | ||
}, | ||
devServer: { | ||
framework: "next", | ||
bundler: "webpack", | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
describe("Navigation", () => { | ||
it("should navigate to the about page", () => { | ||
cy.visit("http://localhost:3000/"); | ||
|
||
cy.get('a[href*="about"]').click(); | ||
|
||
cy.url().should("include", "/about"); | ||
|
||
cy.matchImage().then(({ imgNewPath }) => { | ||
// match against image from custom path | ||
cy.matchImage({ matchAgainstPath: imgNewPath }); | ||
}); | ||
}); | ||
}); | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/// <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> | ||
// } | ||
// } | ||
// } | ||
|
||
import "@frsource/cypress-plugin-visual-regression-diff/dist/support"; | ||
|
||
// Prevent TypeScript from reading file as legacy script | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0" /> | ||
<title>Components App</title> | ||
<!-- Used by Next.js to inject CSS. --> | ||
<div id="__next_css__DO_NOT_USE__"></div> | ||
</head> | ||
<body> | ||
<div data-cy-root></div> | ||
</body> | ||
</html> |
Oops, something went wrong.