@@ -13,56 +13,94 @@ executors:
1313 - *node
1414
1515jobs :
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+
5893workflows :
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
0 commit comments