Skip to content

Commit 1c3a69b

Browse files
committed
feat: initial commit
1 parent f06126a commit 1c3a69b

File tree

15 files changed

+1146
-37
lines changed

15 files changed

+1146
-37
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
},
4242
"dependencies": {
4343
"@wdio/visual-service": "workspace:^",
44-
"@wdio/ocr-service": "workspace:^"
44+
"@wdio/ocr-service": "workspace:^",
45+
"@wdio/storybook-runner": "workspace:^"
4546
},
4647
"devDependencies": {
4748
"@changesets/cli": "^2.27.7",
@@ -78,4 +79,4 @@
7879
"vitest": "^1.6.0",
7980
"webdriverio": "^9.0.0-alpha.351"
8081
}
81-
}
82+
}

packages/storybook-runner/.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
tsconfig.json
2+
src
3+
tests
4+
*.tgz

packages/storybook-runner/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 OpenJS Foundation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/storybook-runner/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# WebdriverIO Storybook Runner
2+
3+
> A WebdriverIO browser runner for easily running Storybook tests.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@wdio/storybook-runner",
3+
"author": "Wim Selles - wswebcreation",
4+
"description": "A WebdriverIO browser runner to run Visual Testing on Storybook",
5+
"version": "1.0.2",
6+
"license": "MIT",
7+
"homepage": "https://webdriver.io/docs/visual-testing",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/webdriverio/visual-testing.git"
11+
},
12+
"keywords": [
13+
"webdriverio",
14+
"visual",
15+
"regression",
16+
"image",
17+
"comparison",
18+
"storybook"
19+
],
20+
"exports": "./dist/index.js",
21+
"type": "module",
22+
"types": "./dist/index.d.ts",
23+
"scripts": {
24+
"build": "run-s clean build:*",
25+
"build:tsc": "tsc --project ./tsconfig.json",
26+
"clean": "rimraf coverage dist .tmp",
27+
"watch": "pnpm run build:tsc -w"
28+
},
29+
"dependencies": {
30+
"@wdio/globals": "^8.38.2",
31+
"@wdio/local-runner": "^8.38.2",
32+
"@wdio/logger": "^8.38.0",
33+
"@wdio/types": "^8.38.2",
34+
"@wdio/visual-service": "^5.1.0",
35+
"node-fetch": "^3.3.2"
36+
},
37+
"devDependencies": {}
38+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const FRAMEWORK_SUPPORT_ERROR = 'Running Storybook in combination with the cucumber framework adapter is not supported.\nOnly Jasmine and Mocha are supported.'
2+
export const MULTIREMOTE_CAPABILITIES_ERROR = 'Running Storybook in combination with Multiremote is not supported.\nRemove your `capabilities` property from your config or assign an empty array to it like `capabilities: [],'
3+
4+
export const V6_CLIP_SELECTOR = '#root > :first-child:not(script):not(style)'
5+
export const CLIP_SELECTOR = '#storybook-root > :first-child:not(script):not(style)'
6+
export const NUM_SHARDS = 1
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
import type { EmulatedDeviceType } from './types.js'
2+
3+
// This is a reflection of what the Chromium Devtools provides for device emulation
4+
// https://source.chromium.org/chromium/chromium/src/+/main:out/fuchsia-Debug/gen/third_party/devtools-frontend/src/front_end/models/emulation/emulation.js?q=%22iPhone%204%22&ss=chromium
5+
export const deviceDescriptors: EmulatedDeviceType[]= [
6+
{
7+
'name': 'iPad Mini',
8+
'screen': {
9+
'dpr': 2,
10+
'width': 1024,
11+
'height': 768
12+
},
13+
'userAgent': 'Mozilla/5.0 (iPad; CPU OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'
14+
},
15+
{
16+
'name': 'iPad',
17+
'screen': {
18+
'dpr': 2,
19+
'width': 1024,
20+
'height': 768
21+
},
22+
'userAgent': 'Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1'
23+
},
24+
{
25+
'name': 'iPad Pro',
26+
'screen': {
27+
'dpr': 2,
28+
'width': 1366,
29+
'height': 1024
30+
},
31+
'userAgent': 'Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1'
32+
},
33+
{
34+
'name': 'iPhone SE',
35+
'screen': {
36+
'dpr': 2,
37+
'width': 320,
38+
'height': 568
39+
},
40+
'userAgent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/17.4 Mobile/14E304 Safari/602.1'
41+
},
42+
{
43+
'name': 'iPhone X',
44+
'screen': {
45+
'dpr': 3,
46+
'width': 375,
47+
'height': 812
48+
},
49+
'userAgent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/17.4 Mobile/15A372 Safari/604.1'
50+
},
51+
{
52+
'name': 'iPhone XR',
53+
'screen': {
54+
'dpr': 3,
55+
'width': 414,
56+
'height': 896
57+
},
58+
'userAgent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1'
59+
},
60+
{
61+
'name': 'iPhone 13',
62+
'screen': {
63+
'dpr': 3,
64+
'width': 390,
65+
'height': 844
66+
},
67+
'userAgent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1'
68+
},
69+
{
70+
'name': 'iPhone 14 Plus',
71+
'screen': {
72+
'dpr': 3,
73+
'width': 428,
74+
'height': 926
75+
},
76+
'userAgent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1'
77+
},
78+
{
79+
'name': 'iPhone 14 Pro',
80+
'screen': {
81+
'dpr': 3,
82+
'width': 393,
83+
'height': 852
84+
},
85+
'userAgent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1'
86+
},
87+
{
88+
'name': 'iPhone 14 Pro Max',
89+
'screen': {
90+
'dpr': 3,
91+
'width': 430,
92+
'height': 932
93+
},
94+
'userAgent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1'
95+
},
96+
{
97+
'name': 'Pixel 2',
98+
'screen': {
99+
'dpr': 2.625,
100+
'width': 411,
101+
'height': 731,
102+
},
103+
'userAgent': 'Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36'
104+
},
105+
{
106+
'name': 'Pixel 2 XL',
107+
'screen': {
108+
'dpr': 3.5,
109+
'width': 411,
110+
'height': 823,
111+
},
112+
'userAgent': 'Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36'
113+
},
114+
{
115+
'name': 'Pixel 3',
116+
'screen': {
117+
'dpr': 2.75,
118+
'width': 393,
119+
'height': 786,
120+
},
121+
'userAgent': 'Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.158 Mobile Safari/537.36'
122+
},
123+
{
124+
'name': 'Pixel 4',
125+
'screen': {
126+
'dpr': 3,
127+
'width': 353,
128+
'height': 745,
129+
},
130+
'userAgent': 'Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36'
131+
},
132+
{
133+
'name': 'Pixel 3 XL',
134+
'screen': {
135+
'dpr': 2.75,
136+
'width': 393,
137+
'height': 786,
138+
},
139+
'userAgent': 'Mozilla/5.0 (Linux; Android 11; Pixel 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Mobile Safari/537.36'
140+
},
141+
{
142+
'name': 'Pixel 7',
143+
'screen': {
144+
'dpr': 2.625,
145+
'width': 412,
146+
'height': 915,
147+
},
148+
'userAgent': 'Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.36'
149+
},
150+
{
151+
'name': 'Samsung Galaxy A51/71',
152+
'screen': {
153+
'dpr': 2.625,
154+
'width': 412,
155+
'height': 914,
156+
},
157+
'userAgent': 'Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.36'
158+
},
159+
{
160+
'name': 'Samsung Galaxy S8+',
161+
'screen': {
162+
'dpr': 4,
163+
'width': 360,
164+
'height': 740,
165+
},
166+
'userAgent': 'Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.36'
167+
},
168+
{
169+
'name': 'Galaxy Z Fold 5',
170+
'screen': {
171+
'dpr': 2.625,
172+
'width': 344,
173+
'height': 882,
174+
},
175+
'userAgent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36'
176+
},
177+
{
178+
'name': 'Galaxy S8',
179+
'screen': {
180+
'dpr': 3,
181+
'width': 360,
182+
'height': 740,
183+
},
184+
'userAgent': 'Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36'
185+
},
186+
{
187+
'name': 'Galaxy S9+',
188+
'screen': {
189+
'dpr': 4.5,
190+
'width': 320,
191+
'height': 658,
192+
},
193+
'userAgent': 'Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.111 Mobile Safari/537.36'
194+
},
195+
{
196+
'name': 'Galaxy Tab S4',
197+
'screen': {
198+
'dpr': 2.25,
199+
'width': 712,
200+
'height': 1138,
201+
},
202+
'userAgent': 'Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.80 Safari/537.36',
203+
},
204+
{
205+
'name': 'Surface Pro 7',
206+
'screen': {
207+
'dpr': 2,
208+
'height': 912,
209+
'width': 1368,
210+
},
211+
'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'
212+
},
213+
{
214+
'name': 'Surface Duo',
215+
'screen': {
216+
'dpr': 2.5,
217+
'height': 540,
218+
'width': 720,
219+
},
220+
'userAgent': 'Mozilla/5.0 (Linux; Android 11.0; Surface Duo) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36'
221+
},
222+
]

0 commit comments

Comments
 (0)