Skip to content

Commit e91279c

Browse files
committed
Added cypress e2e testing framework, moved jest tests to component folders
1 parent 1200661 commit e91279c

File tree

16 files changed

+1075
-8
lines changed

16 files changed

+1075
-8
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ jobs:
4343
key: v1-circleci-nextjs-project-{{ .Branch }}-{{ .Revision }}
4444
- run:
4545
name: Jest tests
46-
command: cd build_path && npm run test:unit
46+
command: cd build_path && npm run test:jest
4747
- store_artifacts:
4848
path: ~/project/build_path/src/tests/__image_snapshots__/__diff_output__
4949
destination: diff_output
5050
- run:
5151
name: Update image snapshots when tests fails
52-
command: cd build_path && npm run test:unit -- -u
52+
command: cd build_path && npm run test:jest:update
5353
when: on_fail
5454
- store_artifacts:
5555
path: ~/project/build_path/src/tests/__image_snapshots__

cypress.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"baseUrl": "http://localhost:3000",
3+
"testFiles": "**/*.*spec.*",
4+
"ignoreTestFiles": ["**/__snapshots__/*", "**/__image_snapshots__/*"],
5+
"pluginsFile": "cypress/plugins/index.ts",
6+
"supportFile": "cypress/support/index.ts",
7+
"video": false
8+
}

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {
2+
smallBreakpoint,
3+
mediumBreakpoint,
4+
largeBreakpoint,
5+
} from "@/utils/constants";
6+
7+
describe("The Home Page", () => {
8+
it("successfully loads homepage", () => {
9+
cy.visit("/");
10+
});
11+
});

cypress/plugins/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference types="cypress" />
2+
// const { initPlugin } = require("cypress-plugin-snapshots/plugin");
3+
4+
// module.exports = (on, config) => {
5+
// initPlugin(on, config);
6+
// return config;
7+
// };
8+
9+
// import { initPlugin } from "cypress-plugin-snapshots/plugin";
10+
11+
// export default (on, config) => {
12+
// initPlugin(on, config);
13+
// return config;
14+
// };

cypress/support/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// import "cypress-plugin-snapshots/commands";

cypress/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": true,
5+
"types": ["cypress"]
6+
},
7+
"include": [
8+
"../node_modules/cypress",
9+
"./**/*.ts"
10+
]
11+
}

jest.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ module.exports = {
22
verbose: true,
33
testEnvironment: "jsdom",
44
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
5-
testPathIgnorePatterns: ["<rootDir>/.next/", "<rootDir>/node_modules/"],
5+
testPathIgnorePatterns: [
6+
"<rootDir>/cypress/",
7+
"<rootDir>/.next/",
8+
"<rootDir>/node_modules/",
9+
],
610
moduleNameMapper: {
711
"\\.(scss|sass|css)$": "identity-obj-proxy",
812
"@/components/(.*)": "<rootDir>/src/components/$1",
13+
"@/utils/(.*)": "<rootDir>/src/utils/$1",
914
},
1015
};

0 commit comments

Comments
 (0)