-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing improvements milan #104
Open
toncic
wants to merge
14
commits into
main
Choose a base branch
from
testing-improvents-milan
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
830b078
Added testing library and jest npm packages
osheinonen 45b7961
Added jest and babel configs, updated tsconfig to support path aliases
osheinonen d910dcc
Created an example welcome component and an unit test for it
osheinonen 672da75
Added visual regression test for unit test
osheinonen 1200661
CircleCi config
osheinonen e91279c
Added cypress e2e testing framework, moved jest tests to component fo…
osheinonen 822f44b
CircleCI config updated
osheinonen d2bb9f9
Visual regression test
osheinonen b0c91f2
Cypress config updated
osheinonen 9dbf3cc
Error
osheinonen ae33e1e
Revert "Error"
osheinonen dc848d6
Fail
osheinonen 7418ab0
Revert "Fail"
osheinonen 7b836b5
Adding test folder and moving jest in it.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["next/babel"] | ||
} |
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 |
---|---|---|
|
@@ -3,10 +3,104 @@ version: 2.1 | |
orbs: | ||
silta: silta/[email protected] | ||
|
||
images: | ||
- &node | ||
image: circleci/node:12.16.1-browsers | ||
|
||
executors: | ||
node: | ||
docker: | ||
- *node | ||
|
||
jobs: | ||
install: | ||
executor: node | ||
steps: | ||
- checkout: | ||
path: ~/project/build_path | ||
- restore_cache: | ||
keys: | ||
- v1-circleci-nextjs-dependencies-{{ .Branch }}-{{ .Revision }} | ||
- run: | ||
name: Install Dependencies | ||
command: cd build_path && npm ci | ||
- save_cache: | ||
key: v1-circleci-nextjs-dependencies-{{ .Branch }}-{{ .Revision }} | ||
paths: | ||
- ~/.npm | ||
- ~/.cache | ||
jest: | ||
docker: | ||
- image: circleci/node:12.16.1-browsers | ||
resource_class: large | ||
steps: | ||
- checkout: | ||
path: ~/project/build_path | ||
- restore_cache: | ||
key: v1-circleci-nextjs-dependencies-{{ .Branch }}-{{ .Revision }} | ||
- run: | ||
name: Install dependencies | ||
command: cd build_path && npm ci | ||
- run: | ||
name: Jest tests | ||
command: cd build_path && npm run test:jest | ||
- store_artifacts: | ||
path: ~/project/build_path/tests/jest/snapshots/diff_output | ||
destination: tests/jest/snapshots/diff_output | ||
- run: | ||
name: Update image snapshots when tests fails | ||
command: cd build_path && npm run test:jest:update | ||
when: on_fail | ||
- store_artifacts: | ||
path: ~/project/build_path/tests/jest/snapshots/current_output | ||
destination: tests/jest/snapshots/current_output | ||
cypress: | ||
docker: | ||
- image: circleci/node:12.16.1-browsers | ||
resource_class: large | ||
steps: | ||
- checkout: | ||
path: ~/project/build_path | ||
- restore_cache: | ||
key: v1-circleci-nextjs-dependencies-{{ .Branch }}-{{ .Revision }} | ||
- run: | ||
name: Install dependencies | ||
command: cd build_path && npm ci | ||
- run: | ||
name: Build application | ||
command: cd build_path && npm run build | ||
- run: | ||
name: Run application | ||
command: cd build_path && npm run start | ||
background: true | ||
- run: | ||
name: Cypress tests | ||
command: cd build_path && npm run test:cypress:run | ||
- store_artifacts: | ||
path: ~/project/build_path/cypress/screenshots | ||
destination: cypress/screenshots | ||
- store_artifacts: | ||
path: ~/project/build_path/cypress/snapshots/diff_output | ||
destination: cypress/snapshots/diff_output | ||
- run: | ||
name: Update image snapshots when tests fails | ||
command: cd build_path && npm run test:cypress:run:update | ||
when: on_fail | ||
- store_artifacts: | ||
path: ~/project/build_path/cypress/snapshots/current_output | ||
destination: cypress/snapshots/current_output | ||
|
||
workflows: | ||
version: 2 | ||
commit: | ||
jobs: | ||
- install | ||
- jest: | ||
requires: | ||
- install | ||
- cypress: | ||
requires: | ||
- install | ||
# silta/frontend-build-deploy is defined here https://github.com/wunderio/silta-circleci/blob/master/orb/jobs/%40frontend.yml | ||
# &build-deploy is a yaml anchor, so we can reference it later | ||
- silta/frontend-build-deploy: &frontend-build-deploy | ||
|
@@ -19,7 +113,6 @@ workflows: | |
filters: | ||
branches: | ||
ignore: production | ||
|
||
- silta/frontend-build-deploy: | ||
# Extend the build-deploy configuration for the production environment. | ||
<<: *frontend-build-deploy | ||
|
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,8 @@ | ||
{ | ||
"baseUrl": "http://localhost:3000", | ||
"testFiles": "**/*.*spec.*", | ||
"ignoreTestFiles": ["**/snapshots/*"], | ||
"pluginsFile": "cypress/plugins/index.ts", | ||
"supportFile": "cypress/support/index.ts", | ||
"video": false | ||
} |
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,15 @@ | ||
import { breakpointList } from "../../tests/test-utils/constants"; | ||
|
||
describe("Home page", () => { | ||
it("should successfully load", () => { | ||
cy.visit("/"); | ||
}); | ||
|
||
breakpointList.forEach((width) => { | ||
it(`should match current snapshot ('${width}px' viewport width)`, () => { | ||
cy.viewport(width, 1080); | ||
cy.visit(`/`); | ||
cy.matchImageSnapshot(); | ||
}); | ||
}); | ||
}); |
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,7 @@ | ||
/// <reference types="cypress" /> | ||
import { addMatchImageSnapshotPlugin } from "cypress-image-snapshot/plugin"; | ||
|
||
export default (on, config) => { | ||
addMatchImageSnapshotPlugin(on, config); | ||
return config; | ||
}; |
Binary file added
BIN
+9.24 KB
...s/Home page -- should match current snapshot ('1024px' viewport width).snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.07 KB
...ts/Home page -- should match current snapshot ('480px' viewport width).snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
import { addMatchImageSnapshotCommand } from "cypress-image-snapshot/command"; | ||
|
||
addMatchImageSnapshotCommand({ | ||
customSnapshotsDir: "cypress/snapshots/current_output", | ||
customDiffDir: "cypress/snapshots/diff_output", | ||
}); | ||
|
||
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,11 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": true, | ||
"types": ["cypress"] | ||
}, | ||
"include": [ | ||
"../node_modules/cypress", | ||
"./**/*.ts" | ||
] | ||
} |
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,15 @@ | ||
module.exports = { | ||
verbose: true, | ||
testEnvironment: "jsdom", | ||
setupFilesAfterEnv: ["<rootDir>/tests/jest/jest.setup.ts"], | ||
testPathIgnorePatterns: [ | ||
"<rootDir>/cypress/", | ||
"<rootDir>/.next/", | ||
"<rootDir>/node_modules/", | ||
], | ||
moduleNameMapper: { | ||
"\\.(scss|sass|css)$": "identity-obj-proxy", | ||
"@/components/(.*)": "<rootDir>/src/components/$1", | ||
"@/utils/(.*)": "<rootDir>/src/utils/$1", | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node 16 LTS is out, I'd use that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think circleci have deprecated these images in favour of convenience images (
cimg
). Here are the node ones:https://circleci.com/developer/images/image/cimg/node