Skip to content

Commit 822f44b

Browse files
committed
CircleCI config updated
1 parent e91279c commit 822f44b

File tree

12 files changed

+409
-44
lines changed

12 files changed

+409
-44
lines changed

.circleci/config.yml

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,94 @@ executors:
1313
- *node
1414

1515
jobs:
16-
build:
16+
install:
1717
executor: node
1818
steps:
1919
- checkout:
2020
path: ~/project/build_path
2121
- restore_cache:
22-
key: v1-circleci-nextjs-project-{{ .Branch }}-{{ .Revision }}
22+
keys:
23+
- v1-circleci-nextjs-dependecies-{{ .Branch }}-{{ .Revision }}
2324
- run:
2425
name: Install Dependencies
25-
command: cd build_path && npm install
26-
- run:
27-
name: Build
28-
command: cd build_path && npm run build
29-
30-
# Cache node_modules for tests.
26+
command: cd build_path && npm ci
3127
- save_cache:
32-
key: v1-circleci-nextjs-project-{{ .Branch }}-{{ .Revision }}
28+
key: v1-circleci-nextjs-dependecies-{{ .Branch }}-{{ .Revision }}
3329
paths:
34-
- build_path
35-
36-
unit-test:
30+
- ~/.npm
31+
- ~/.cache
32+
jest:
3733
docker:
3834
- image: circleci/node:12.16.1-browsers
3935
resource_class: large
4036
steps:
41-
- checkout
37+
- checkout:
38+
path: ~/project/build_path
4239
- restore_cache:
43-
key: v1-circleci-nextjs-project-{{ .Branch }}-{{ .Revision }}
40+
key: v1-circleci-nextjs-dependecies-{{ .Branch }}-{{ .Revision }}
41+
- run:
42+
name: Install dependecies
43+
command: cd build_path && npm ci
4444
- run:
4545
name: Jest tests
4646
command: cd build_path && npm run test:jest
4747
- store_artifacts:
48-
path: ~/project/build_path/src/tests/__image_snapshots__/__diff_output__
49-
destination: diff_output
48+
path: ~/project/build_path/jest/snapshots/diff_output
49+
# destination: jest/diff_output
5050
- run:
5151
name: Update image snapshots when tests fails
5252
command: cd build_path && npm run test:jest:update
5353
when: on_fail
5454
- store_artifacts:
55-
path: ~/project/build_path/src/tests/__image_snapshots__
56-
destination: image_snapshots
57-
55+
path: ~/project/build_path/jest/snapshots/current_output
56+
# destination: jest/image_snapshots
57+
cypress:
58+
docker:
59+
- image: circleci/node:12.16.1-browsers
60+
resource_class: large
61+
steps:
62+
- checkout:
63+
path: ~/project/build_path
64+
- restore_cache:
65+
key: v1-circleci-nextjs-dependecies-{{ .Branch }}-{{ .Revision }}
66+
- run:
67+
name: Install dependecies
68+
command: cd build_path && npm ci
69+
- run:
70+
name: Build application
71+
command: cd build_path && npm run build
72+
- run:
73+
name: Run application
74+
command: cd build_path && npm run start
75+
background: true
76+
- run:
77+
name: Cypress tests
78+
command: cd build_path && npm run test:cypress:run
79+
- store_artifacts:
80+
path: ~/project/build_path/cypress/screenshots
81+
# destination: cypress/screenshots
82+
- store_artifacts:
83+
path: ~/project/build_path/cypress/snapshots/diff_output
84+
# destination: cypress/diff_output
85+
- run:
86+
name: Update image snapshots when tests fails
87+
command: cd build_path && npm run test:cypress:run:update
88+
when: on_fail
89+
- store_artifacts:
90+
path: ~/project/build_path/cypress/snapshots/current_output
91+
# destination: cypress/image_snapshots
92+
5893
workflows:
5994
version: 2
6095
commit:
6196
jobs:
62-
- build
63-
- unit-test:
97+
- install
98+
- jest:
99+
requires:
100+
- install
101+
- cypress:
64102
requires:
65-
- build
103+
- install
66104
# silta/frontend-build-deploy is defined here https://github.com/wunderio/silta-circleci/blob/master/orb/jobs/%40frontend.yml
67105
# &build-deploy is a yaml anchor, so we can reference it later
68106
- silta/frontend-build-deploy: &frontend-build-deploy
@@ -75,7 +113,6 @@ workflows:
75113
filters:
76114
branches:
77115
ignore: production
78-
79116
- silta/frontend-build-deploy:
80117
# Extend the build-deploy configuration for the production environment.
81118
<<: *frontend-build-deploy

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
/.pnp
66
.pnp.js
77

8-
# testing
9-
/coverage
8+
# testing image snapshot diffs
9+
/cypress/snapshots/diff_output
10+
/jest/snapshots/diff_output
11+
12+
# cypress screenshots
13+
/cypress/screenshots
1014

1115
# next.js
1216
/.next/

cypress/integration/home-page.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ import {
77
describe("The Home Page", () => {
88
it("successfully loads homepage", () => {
99
cy.visit("/");
10+
cy.matchImageSnapshot();
1011
});
1112
});

cypress/plugins/index.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
/// <reference types="cypress" />
2-
// const { initPlugin } = require("cypress-plugin-snapshots/plugin");
2+
import { addMatchImageSnapshotPlugin } from "cypress-image-snapshot/plugin";
33

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-
// };
4+
export default (on, config) => {
5+
addMatchImageSnapshotPlugin(on, config);
6+
return config;
7+
};
6.84 KB
Loading

cypress/support/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
// import "cypress-plugin-snapshots/commands";
1+
import { addMatchImageSnapshotCommand } from "cypress-image-snapshot/command";
2+
3+
addMatchImageSnapshotCommand({
4+
customSnapshotsDir: "cypress/snapshots/current_output",
5+
customDiffDir: "cypress/snapshots/diff_output",
6+
});
7+
8+
export {};

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
verbose: true,
33
testEnvironment: "jsdom",
4-
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
4+
setupFilesAfterEnv: ["<rootDir>/jest/jest.setup.ts"],
55
testPathIgnorePatterns: [
66
"<rootDir>/cypress/",
77
"<rootDir>/.next/",

jest.setup.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

jest/jest.setup.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { expect } from "@jest/globals";
2+
import "@testing-library/jest-dom";
3+
import { configureToMatchImageSnapshot } from "jest-image-snapshot";
4+
5+
const toMatchImageSnapshot = configureToMatchImageSnapshot({
6+
customSnapshotsDir: "jest/snapshots/current_output",
7+
customDiffDir: "jest/snapshots/diff_output",
8+
});
9+
10+
expect.extend({ toMatchImageSnapshot });

0 commit comments

Comments
 (0)