Skip to content

Commit

Permalink
chore: component visual regression tests using percy (#166)
Browse files Browse the repository at this point in the history
* [DES-381] Component Visual Regression test with Percy

* changeset

* Adding script to root

* fixing formatting

* Updated github actions to use new script

* updated package.josn

* Fixed typo
  • Loading branch information
Ashley-p44 authored Dec 12, 2022
1 parent 1b5bdf2 commit c69dc25
Show file tree
Hide file tree
Showing 8 changed files with 326 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-wolves-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@project44-manifest/storybook': minor
---

Add Percy visual regression tests
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:

env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}

Expand Down Expand Up @@ -39,3 +40,6 @@ jobs:

- name: Run Jest
run: yarn test

- name: Run Percy tests
run: yarn test:visual
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ apps/**/sitemap.xml
!.yarn/versions

# turborepo
.turbo
.turbo

# environment variables
.env
14 changes: 14 additions & 0 deletions .percy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
snapshot:
widths:
- 1280
minHeight: 1024
percyCSS: ''
discovery:
allowedHostnames: []
disallowedHostnames: []
networkIdleTimeout: 100
upload:
files: '**/*.{png,jpg,jpeg}'
ignore: ''
stripExtensions: false
8 changes: 7 additions & 1 deletion apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"scripts": {
"build": "build-storybook -c .storybook -o ./build",
"dev": "start-storybook -p 6006 --quiet",
"clean": "rm -rf .turbo node_modules build"
"clean": "rm -rf .turbo node_modules build",
"percy": "percy storybook ./build",
"test:visual": "yarn build && yarn percy"
},
"dependencies": {
"@project44-manifest/react": "*",
Expand All @@ -16,5 +18,9 @@
"react": "^18.1.0",
"react-dom": "^18.1.0",
"webpack": "^5.74.0"
},
"devDependencies": {
"@percy/cli": "^1.16.0",
"@percy/storybook": "^4.3.4"
}
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
"dev": "turbo run dev",
"format": "prettier --check \"**/*.{ts,tsx,md}\"",
"lint": "eslint --ext .tsx,.ts ./packages",
"percy": "yarn ./apps/storybook/ exec percy storybook ./build",
"prepare": "husky install",
"release-packages": "yarn build && yarn changeset publish",
"storybook:build": "yarn turbo run build --filter=@project44-manifest/storybook",
"test": "jest",
"test:visual": "yarn storybook:build && yarn percy",
"typecheck": "turbo run typecheck",
"version-packages": "yarn changeset version"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-tooltip/stories/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
};

const Template: ComponentStory<typeof Tooltip> = (args) => (
<Tooltip {...args} title="Tooltip">
<Tooltip defaultOpen {...args} title="Tooltip">
<button>Hover Me</button>
</Tooltip>
);
Expand Down
Loading

0 comments on commit c69dc25

Please sign in to comment.