creevey 0.9.0-beta.2 → 0.9.0-non-webpack.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/AUTHORS +15 -15
  2. package/CHANGELOG.md +1275 -1275
  3. package/LICENSE +21 -21
  4. package/README.md +7 -0
  5. package/addon/README.md +3 -0
  6. package/addon/package.json +4 -0
  7. package/docs/config.md +212 -212
  8. package/docs/grid.md +10 -10
  9. package/docs/tests.md +63 -63
  10. package/jest.config.js +6 -0
  11. package/lib/cjs/client/addon/Manager.js +11 -5
  12. package/lib/cjs/client/addon/components/Addon.js +1 -1
  13. package/lib/cjs/client/addon/components/Icons.js +2 -2
  14. package/lib/cjs/client/addon/components/Tools.js +1 -1
  15. package/lib/cjs/client/addon/index.js +31 -0
  16. package/lib/cjs/client/addon/preset.js +3 -3
  17. package/lib/cjs/client/addon/register.js +7 -3
  18. package/lib/cjs/client/addon/withCreevey.js +57 -30
  19. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +1 -1
  20. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +1 -1
  21. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +1 -1
  22. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +1 -1
  23. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +1 -1
  24. package/lib/cjs/client/shared/components/ImagesView/index.js +4 -4
  25. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +1 -1
  26. package/lib/cjs/client/shared/components/ResultsPage.js +2 -2
  27. package/lib/cjs/client/shared/creeveyClientApi.js +6 -2
  28. package/lib/cjs/client/shared/helpers.js +22 -22
  29. package/lib/cjs/client/shared/viewMode.js +1 -1
  30. package/lib/cjs/client/web/142.js +2 -0
  31. package/lib/cjs/client/web/142.js.LICENSE.txt +12 -0
  32. package/lib/cjs/client/web/32.js +1 -0
  33. package/lib/cjs/client/web/551.js +1 -0
  34. package/lib/cjs/client/web/566.js +2 -0
  35. package/lib/cjs/client/web/566.js.LICENSE.txt +31 -0
  36. package/lib/cjs/client/web/691.js +2 -0
  37. package/lib/cjs/client/web/691.js.LICENSE.txt +8 -0
  38. package/lib/cjs/client/web/725.js +1 -0
  39. package/lib/cjs/client/web/index.html +19 -19
  40. package/lib/cjs/client/web/main.js +2 -38
  41. package/lib/cjs/client/web/main.js.LICENSE.txt +49 -0
  42. package/lib/cjs/creevey.js +3 -5
  43. package/lib/cjs/index.js +4 -4
  44. package/lib/cjs/server/config.js +1 -1
  45. package/lib/cjs/server/docker.js +3 -7
  46. package/lib/cjs/server/index.js +1 -1
  47. package/lib/cjs/server/loaders/babel/creevey-plugin.js +1 -3
  48. package/lib/cjs/server/loaders/babel/helpers.js +13 -23
  49. package/lib/cjs/server/loaders/babel/register.js +1 -3
  50. package/lib/cjs/server/loaders/webpack/compile.js +31 -24
  51. package/lib/cjs/server/loaders/webpack/creevey-loader.js +10 -5
  52. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +2 -7
  53. package/lib/cjs/server/loaders/webpack/mdx-loader.js +1 -1
  54. package/lib/cjs/server/loaders/webpack/start.js +1 -1
  55. package/lib/cjs/server/logger.js +2 -1
  56. package/lib/cjs/server/master/index.js +2 -2
  57. package/lib/cjs/server/master/pool.js +9 -18
  58. package/lib/cjs/server/master/runner.js +53 -66
  59. package/lib/cjs/server/master/server.js +2 -2
  60. package/lib/cjs/server/messages.js +8 -10
  61. package/lib/cjs/server/selenium/browser.js +23 -31
  62. package/lib/cjs/server/selenium/selenoid.js +5 -7
  63. package/lib/cjs/server/stories.js +9 -20
  64. package/lib/cjs/server/storybook/entry.js +5 -3
  65. package/lib/cjs/server/storybook/helpers.js +15 -21
  66. package/lib/cjs/server/storybook/providers/browser.js +5 -9
  67. package/lib/cjs/server/storybook/providers/nodejs.js +4 -4
  68. package/lib/cjs/server/update.js +1 -5
  69. package/lib/cjs/server/utils.js +13 -15
  70. package/lib/cjs/server/worker/reporter.js +8 -20
  71. package/lib/cjs/server/worker/worker.js +6 -16
  72. package/lib/cjs/shared/index.js +89 -0
  73. package/lib/cjs/shared/serializeRegExp.js +41 -0
  74. package/lib/cjs/types.js +6 -6
  75. package/lib/esm/client/addon/Manager.js +11 -5
  76. package/lib/esm/client/addon/components/Icons.js +1 -1
  77. package/lib/esm/client/addon/index.js +2 -0
  78. package/lib/esm/client/addon/preset.js +1 -1
  79. package/lib/esm/client/addon/register.js +6 -2
  80. package/lib/esm/client/addon/withCreevey.js +55 -30
  81. package/lib/esm/client/shared/creeveyClientApi.js +6 -2
  82. package/lib/esm/client/shared/helpers.js +6 -6
  83. package/lib/esm/creevey.js +3 -5
  84. package/lib/esm/index.js +1 -3
  85. package/lib/esm/server/docker.js +2 -2
  86. package/lib/esm/server/index.js +1 -1
  87. package/lib/esm/server/loaders/babel/creevey-plugin.js +1 -3
  88. package/lib/esm/server/loaders/babel/helpers.js +12 -22
  89. package/lib/esm/server/loaders/babel/register.js +1 -3
  90. package/lib/esm/server/loaders/webpack/compile.js +31 -24
  91. package/lib/esm/server/loaders/webpack/creevey-loader.js +9 -4
  92. package/lib/esm/server/loaders/webpack/dummy-hmr.js +2 -6
  93. package/lib/esm/server/loaders/webpack/start.js +1 -1
  94. package/lib/esm/server/master/index.js +2 -2
  95. package/lib/esm/server/master/pool.js +7 -18
  96. package/lib/esm/server/master/runner.js +53 -66
  97. package/lib/esm/server/master/server.js +2 -2
  98. package/lib/esm/server/messages.js +3 -5
  99. package/lib/esm/server/selenium/browser.js +20 -28
  100. package/lib/esm/server/selenium/selenoid.js +4 -6
  101. package/lib/esm/server/stories.js +9 -20
  102. package/lib/esm/server/storybook/entry.js +4 -2
  103. package/lib/esm/server/storybook/helpers.js +7 -15
  104. package/lib/esm/server/storybook/providers/browser.js +4 -5
  105. package/lib/esm/server/storybook/providers/nodejs.js +3 -3
  106. package/lib/esm/server/update.js +1 -5
  107. package/lib/esm/server/utils.js +5 -9
  108. package/lib/esm/server/worker/reporter.js +8 -20
  109. package/lib/esm/server/worker/worker.js +6 -16
  110. package/lib/esm/shared/index.js +66 -0
  111. package/lib/esm/shared/serializeRegExp.js +23 -0
  112. package/lib/types/cli.d.ts +1 -1
  113. package/lib/types/client/addon/Manager.d.ts +37 -37
  114. package/lib/types/client/addon/components/Addon.d.ts +8 -8
  115. package/lib/types/client/addon/components/Icons.d.ts +7 -7
  116. package/lib/types/client/addon/components/Panel.d.ts +9 -9
  117. package/lib/types/client/addon/components/TestSelect.d.ts +8 -9
  118. package/lib/types/client/addon/components/Tools.d.ts +6 -6
  119. package/lib/types/client/addon/decorator.d.ts +1 -1
  120. package/lib/types/client/addon/index.d.ts +2 -0
  121. package/lib/types/client/addon/preset.d.ts +23 -24
  122. package/lib/types/client/addon/readyForCapture.d.ts +6 -6
  123. package/lib/types/client/addon/register.d.ts +3 -3
  124. package/lib/types/client/addon/utils.d.ts +2 -2
  125. package/lib/types/client/addon/withCreevey.d.ts +24 -24
  126. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +3 -3
  127. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +24 -25
  128. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +3 -3
  129. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +3 -3
  130. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +3 -3
  131. package/lib/types/client/shared/components/ImagesView/index.d.ts +5 -5
  132. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +8 -9
  133. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +7 -8
  134. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +12 -12
  135. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +16 -17
  136. package/lib/types/client/shared/components/ResultsPage.d.ts +18 -18
  137. package/lib/types/client/shared/creeveyClientApi.d.ts +9 -9
  138. package/lib/types/client/shared/helpers.d.ts +46 -46
  139. package/lib/types/client/shared/viewMode.d.ts +4 -4
  140. package/lib/types/client/web/CreeveyApp.d.ts +11 -12
  141. package/lib/types/client/web/CreeveyContext.d.ts +11 -11
  142. package/lib/types/client/web/CreeveyLoader.d.ts +2 -3
  143. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +19 -19
  144. package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +6 -6
  145. package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +14 -14
  146. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +12 -13
  147. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +33 -33
  148. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +7 -8
  149. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +10 -10
  150. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +9 -9
  151. package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +6 -6
  152. package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +1 -1
  153. package/lib/types/client/web/KeyboardEventsContext.d.ts +13 -13
  154. package/lib/types/client/web/index.d.ts +4 -4
  155. package/lib/types/creevey.d.ts +1 -1
  156. package/lib/types/index.d.ts +0 -1
  157. package/lib/types/server/config.d.ts +4 -4
  158. package/lib/types/server/docker.d.ts +7 -7
  159. package/lib/types/server/extract.d.ts +2 -2
  160. package/lib/types/server/index.d.ts +2 -2
  161. package/lib/types/server/loaders/babel/creevey-plugin.d.ts +1 -1
  162. package/lib/types/server/loaders/babel/helpers.d.ts +19 -19
  163. package/lib/types/server/loaders/babel/register.d.ts +5 -5
  164. package/lib/types/server/loaders/hooks/mdx.d.ts +1 -1
  165. package/lib/types/server/loaders/hooks/svelte.d.ts +1 -1
  166. package/lib/types/server/loaders/webpack/compile.d.ts +2 -2
  167. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
  168. package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +10 -10
  169. package/lib/types/server/loaders/webpack/mdx-loader.d.ts +6 -6
  170. package/lib/types/server/loaders/webpack/start.d.ts +1 -1
  171. package/lib/types/server/logger.d.ts +10 -6
  172. package/lib/types/server/master/api.d.ts +7 -7
  173. package/lib/types/server/master/index.d.ts +3 -3
  174. package/lib/types/server/master/master.d.ts +7 -7
  175. package/lib/types/server/master/pool.d.ts +31 -31
  176. package/lib/types/server/master/runner.d.ts +26 -26
  177. package/lib/types/server/master/server.d.ts +2 -2
  178. package/lib/types/server/messages.d.ts +27 -27
  179. package/lib/types/server/selenium/browser.d.ts +17 -17
  180. package/lib/types/server/selenium/index.d.ts +2 -2
  181. package/lib/types/server/selenium/selenoid.d.ts +3 -3
  182. package/lib/types/server/stories.d.ts +8 -8
  183. package/lib/types/server/storybook/entry.d.ts +18 -18
  184. package/lib/types/server/storybook/helpers.d.ts +24 -24
  185. package/lib/types/server/storybook/providers/browser.d.ts +4 -4
  186. package/lib/types/server/storybook/providers/hybrid.d.ts +4 -4
  187. package/lib/types/server/storybook/providers/nodejs.d.ts +9 -9
  188. package/lib/types/server/testsFiles/parser.d.ts +12 -12
  189. package/lib/types/server/testsFiles/register.d.ts +2 -2
  190. package/lib/types/server/update.d.ts +2 -2
  191. package/lib/types/server/utils.d.ts +20 -20
  192. package/lib/types/server/worker/chai-image.d.ts +6 -6
  193. package/lib/types/server/worker/helpers.d.ts +8 -8
  194. package/lib/types/server/worker/index.d.ts +1 -1
  195. package/lib/types/server/worker/reporter.d.ts +8 -8
  196. package/lib/types/server/worker/worker.d.ts +4 -4
  197. package/lib/types/{shared.d.ts → shared/index.d.ts} +7 -16
  198. package/lib/types/shared/serializeRegExp.d.ts +9 -0
  199. package/lib/types/types.d.ts +490 -489
  200. package/package.json +115 -102
  201. package/preset.js +9 -9
  202. package/types/babel__register.d.ts +1 -1
  203. package/types/chai.d.ts +12 -12
  204. package/types/event-source-polyfill.d.ts +6 -6
  205. package/types/mdx.d.ts +3 -2
  206. package/types/mocha.d.ts +20 -20
  207. package/types/png.d.ts +4 -4
  208. package/lib/cjs/client/web/1.js +0 -13
  209. package/lib/cjs/client/web/2.js +0 -1
  210. package/lib/cjs/shared.js +0 -124
  211. package/lib/esm/shared.js +0 -93
  212. package/storybook-static/stories.json +0 -21
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Dmitriy Lazarev
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Dmitriy Lazarev
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.
package/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # 📸+👦🏼 [Creevey](https://harrypotter.fandom.com/wiki/Colin_Creevey)
2
2
 
3
+ **IMPORTANT** _Looking for any help with maintaining_
4
+
3
5
  Cross-browser screenshot testing tool for [Storybook](https://storybook.js.org/) with fancy UI Runner.
4
6
 
5
7
  [![Creevey downloads](https://img.shields.io/npm/dt/creevey)](https://www.npmjs.com/package/creevey)
6
8
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
9
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FwKich%2Fcreevey.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FwKich%2Fcreevey?ref=badge_shield)
7
10
 
8
11
  ![Creevey Demo](https://user-images.githubusercontent.com/6397708/100863723-cd6b8500-34b6-11eb-94e1-849590bc8066.gif)
9
12
 
@@ -145,3 +148,7 @@ Because tests defined in story parameters and `selenium-webdriver` depends on no
145
148
 
146
149
  | [![Whisk](https://raw.githubusercontent.com/wKich/creevey/master/.github/images/whisk.svg)](https://whisk.com/) | [![SKB Kontur](https://kontur.ru/Files/userfiles/image/brandbook/logo-skb-kontur-eng.png)](https://kontur.ru/) | [![ABBYY](https://raw.githubusercontent.com/wKich/creevey/master/.github/images/abbyy.svg)](https://www.abbyy.com/) |
147
150
  | --------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
151
+
152
+ ## License
153
+
154
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FwKich%2Fcreevey.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FwKich%2Fcreevey?ref=badge_large)
@@ -0,0 +1,3 @@
1
+ This is a fallback for package.json's `exports.addon` field. It's required for outdated environments (like node 11 and typescript with the "node" moduleResolution) to resolve imports from `creevey/addon` properly.
2
+
3
+ See https://github.com/andrewbranch/example-subpath-exports-ts-compat. The fallback uses the "package-json-redirects" startegy.
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "../lib/cjs/client/addon/index.js",
3
+ "types": "../lib/types/client/addon/index.d.ts"
4
+ }
package/docs/config.md CHANGED
@@ -1,212 +1,212 @@
1
- ## Config/Options
2
-
3
- ### CLI Options
4
-
5
- - `--config` — Specify path to config file. Default `.creevey/config.js` or `creevey.config.js`
6
- - `--ui` — Start runner web server
7
- - `--update` — Approve all images from `report` directory
8
- - `--port` — Specify port for web server. Default `3000`
9
- - `--reportDir` — Path where reports will be stored
10
- - `--screenDir` — Path where reference images are located
11
- - `--debug` — Enable debug output
12
-
13
- ### Creevey config
14
-
15
- In default configuration Creevey take screenshots of `#root` element only for chrome browser in one concurrent instance, to run tests in different browsers or speedup tests and run in parallel, you need to define config file `.creevey/config.js`
16
-
17
- ```ts
18
- module.exports = {
19
- browsers: {
20
- chrome: {
21
- browserName: 'chrome',
22
- // Define initial viewport size
23
- viewport: { width: 1024, height: 720 },
24
- // Increase parallel sessions
25
- limit: 2,
26
- },
27
- firefox: {
28
- browserName: 'firefox',
29
- viewport: { width: 1024, height: 720 },
30
- },
31
- },
32
- };
33
- ```
34
-
35
- ### All possible config options
36
-
37
- :warning: **WARN** :warning: This config is just an example with all possible options. :warning: **WARN** :warning:
38
-
39
- ```ts
40
- const path = require('path');
41
-
42
- module.exports = {
43
- // Specify custom Selenium Grid url (see usage below)
44
- // In most cases you don't need this option
45
- gridUrl: '<gridUrl>/wd/hub',
46
-
47
- // Default Storybook url
48
- storybookUrl: 'http://localhost:6006',
49
-
50
- // Storybook config directory
51
- storybookDir: path.join(__dirname, '.storybook'),
52
-
53
- // Where original images are stored
54
- screenDir: path.join(__dirname, '../images'),
55
-
56
- // Report directory that contains data from previous runs
57
- reportDir: path.join(__dirname, '../report'),
58
-
59
- // Pixelmatch options
60
- diffOptions: { threshold: 0.1 },
61
-
62
- // How many times test should be retried before to consider it as failed
63
- maxRetries: 2,
64
-
65
- // Describe browsers and their options
66
- browsers: {
67
- // Shorthand declarations of browsers
68
- chrome: true,
69
- ff: 'firefox',
70
-
71
- otherChrome: {
72
- browserName: 'chrome',
73
- // Define initial viewport size
74
- viewport: { width: 1024, height: 720 },
75
- // Increase parallel sessions
76
- limit: 2,
77
- /* Also you can define any browser capabilities here */
78
- version: '86.0',
79
- // It's possible to set Storybook's globals
80
- // https://github.com/storybookjs/storybook/blob/v6.0.0/docs/essentials/toolbars-and-globals.md
81
- // NOTE: This is an experimental feature and will be replaced in future
82
- _storybookGlobals: {
83
- myTheme: 'dark',
84
- },
85
- },
86
-
87
- // You can override some global options for specific browser
88
- ie11: {
89
- browserName: 'internet explorer',
90
- // Like user another Selenium Grid url
91
- gridUrl: '<anotherGridUrl>/wd/hub',
92
- // Or use different storybook instance
93
- storybookUrl: 'http://mystoryhost:6007',
94
- // And use you own docker image
95
- // By default Creevey will use selenoid image according browser name and version:
96
- // `selenoid/${browserName}:${version ?? 'latest'}` image
97
- dockerImage: 'microsoft/ie:11.0',
98
- },
99
- },
100
-
101
- // You may want to do something before tests started (for example start browserstack-local)
102
- hooks: {
103
- async before() {
104
- /* ... */
105
- },
106
- async after() {
107
- /* ... */
108
- },
109
- },
110
- };
111
- ```
112
-
113
- ### Storybook parameters
114
-
115
- Also you could define parameters on `global`, `kind` or `story` levels. All these parameters are deeply merged by Storybook for each story. But bear in mind when you define skip option as an array Storybook treats it as primitive value and doesn't merge with other skip options.
116
-
117
- ```tsx
118
- // .storybook/preview.tsx
119
- export const parameters = {
120
- creevey: {
121
- // Skip all *hover tests in IE11 on the global level
122
- skip: {
123
- ie11: { in: 'ie11', tests: /.*hover$/ },
124
- },
125
- },
126
- };
127
- ```
128
-
129
- ```tsx
130
- import React from 'react';
131
- import { Meta, Story } from '@storybook/react';
132
- import { CreeveyMeta, CreeveyStory } from 'creevey';
133
- import MyComponent from './src/components/MyComponent';
134
-
135
- export default {
136
- title: 'MyComponent'
137
- parameters: {
138
- creevey: {
139
- // You could skip some browsers/stories or even specific tests
140
- skip: [
141
- { in: 'ie11', reason: "`MyComponent` doesn't support ie11" },
142
- { in: 'firefox', stories: 'Loading', reason: "Loading stories are flaky in firefox" },
143
- {
144
- in: ['firefox', 'chrome'],
145
- tests: /.*hover$/,
146
- reason: "For some reason `MyComponent` hovering doesn't work correctly",
147
- },
148
- ],
149
- },
150
- },
151
- } as Meta & CreeveyMeta;
152
-
153
- export const Basic: Story & CreeveyStory = () => <MyComponent />;
154
- Basic.parameters = {
155
- creevey: {
156
- captureElement: '.container',
157
- // elements to ignore in capturing screenshot
158
- ignoreElements: ['button', '.local-time'],
159
- // Delay before test starts in ms
160
- delay: 1000,
161
- tests: {
162
- /* ... */
163
- },
164
- },
165
- };
166
- ```
167
-
168
- ### `skip` option examples:
169
-
170
- ```ts
171
- interface SkipOption {
172
- reason?: string;
173
- in?: string | string[] | RegExp;
174
- kinds?: string | string[] | RegExp;
175
- stories?: string | string[] | RegExp;
176
- tests?: string | string[] | RegExp;
177
- }
178
-
179
- type SkipOptions = SkipOption | SkipOption[] | Record<string, SkipOption | SkipOption[]>;
180
- ```
181
-
182
- - Skip all stories for all browsers:
183
- - `skip: true`
184
- - `skip: 'Skip reason message'`
185
- - `skip: { reason: 'Skip reason message' }`
186
- - Skip all stories for specific browsers:
187
- - `skip: { in: 'ie11' }`
188
- - `skip: { in: ['ie11', 'chrome'] }`
189
- - `skip: { in: /^fire.*/ }`
190
- - Skip all stories in specific kinds:
191
- - `skip: { kinds: 'Button' }`
192
- - `skip: { kinds: ['Button', 'Input'] }`
193
- - `skip: { kinds: /.*Modal$/ }`
194
- - Skip all tests in specific stories:
195
- - `skip: { stories: 'simple' }`
196
- - `skip: { stories: ['simple', 'special'] }`
197
- - `skip: { stories: /.*large$/ }`
198
- - Skip specific tests:
199
- - `skip: { tests: 'click' }`
200
- - `skip: { tests: ['hover', 'click'] }`
201
- - `skip: { tests: /^press.*$/ }`
202
- - Multiple skip options:
203
- - as an array `skip: [{ /* ... */ }]`
204
- - as an object
205
- ```
206
- skip: {
207
- foo: { /* ... */ },
208
- bar: { /* ... */ },
209
- }
210
- ```
211
-
212
- NOTE: If you try to skip stories by story name, the storybook name format will be used (For more info see [storybook-export-vs-name-handling](https://storybook.js.org/docs/formats/component-story-format/#storybook-export-vs-name-handling))
1
+ ## Config/Options
2
+
3
+ ### CLI Options
4
+
5
+ - `--config` — Specify path to config file. Default `.creevey/config.js` or `creevey.config.js`
6
+ - `--ui` — Start runner web server
7
+ - `--update` — Approve all images from `report` directory
8
+ - `--port` — Specify port for web server. Default `3000`
9
+ - `--reportDir` — Path where reports will be stored
10
+ - `--screenDir` — Path where reference images are located
11
+ - `--debug` — Enable debug output
12
+
13
+ ### Creevey config
14
+
15
+ In default configuration Creevey take screenshots of `#root` element only for chrome browser in one concurrent instance, to run tests in different browsers or speedup tests and run in parallel, you need to define config file `.creevey/config.js`
16
+
17
+ ```ts
18
+ module.exports = {
19
+ browsers: {
20
+ chrome: {
21
+ browserName: 'chrome',
22
+ // Define initial viewport size
23
+ viewport: { width: 1024, height: 720 },
24
+ // Increase parallel sessions
25
+ limit: 2,
26
+ },
27
+ firefox: {
28
+ browserName: 'firefox',
29
+ viewport: { width: 1024, height: 720 },
30
+ },
31
+ },
32
+ };
33
+ ```
34
+
35
+ ### All possible config options
36
+
37
+ :warning: **WARN** :warning: This config is just an example with all possible options. :warning: **WARN** :warning:
38
+
39
+ ```ts
40
+ const path = require('path');
41
+
42
+ module.exports = {
43
+ // Specify custom Selenium Grid url (see usage below)
44
+ // In most cases you don't need this option
45
+ gridUrl: '<gridUrl>/wd/hub',
46
+
47
+ // Default Storybook url
48
+ storybookUrl: 'http://localhost:6006',
49
+
50
+ // Storybook config directory
51
+ storybookDir: path.join(__dirname, '.storybook'),
52
+
53
+ // Where original images are stored
54
+ screenDir: path.join(__dirname, '../images'),
55
+
56
+ // Report directory that contains data from previous runs
57
+ reportDir: path.join(__dirname, '../report'),
58
+
59
+ // Pixelmatch options
60
+ diffOptions: { threshold: 0.1 },
61
+
62
+ // How many times test should be retried before to consider it as failed
63
+ maxRetries: 2,
64
+
65
+ // Describe browsers and their options
66
+ browsers: {
67
+ // Shorthand declarations of browsers
68
+ chrome: true,
69
+ ff: 'firefox',
70
+
71
+ otherChrome: {
72
+ browserName: 'chrome',
73
+ // Define initial viewport size
74
+ viewport: { width: 1024, height: 720 },
75
+ // Increase parallel sessions
76
+ limit: 2,
77
+ /* Also you can define any browser capabilities here */
78
+ version: '86.0',
79
+ // It's possible to set Storybook's globals
80
+ // https://github.com/storybookjs/storybook/blob/v6.0.0/docs/essentials/toolbars-and-globals.md
81
+ // NOTE: This is an experimental feature and will be replaced in future
82
+ _storybookGlobals: {
83
+ myTheme: 'dark',
84
+ },
85
+ },
86
+
87
+ // You can override some global options for specific browser
88
+ ie11: {
89
+ browserName: 'internet explorer',
90
+ // Like user another Selenium Grid url
91
+ gridUrl: '<anotherGridUrl>/wd/hub',
92
+ // Or use different storybook instance
93
+ storybookUrl: 'http://mystoryhost:6007',
94
+ // And use you own docker image
95
+ // By default Creevey will use selenoid image according browser name and version:
96
+ // `selenoid/${browserName}:${version ?? 'latest'}` image
97
+ dockerImage: 'microsoft/ie:11.0',
98
+ },
99
+ },
100
+
101
+ // You may want to do something before tests started (for example start browserstack-local)
102
+ hooks: {
103
+ async before() {
104
+ /* ... */
105
+ },
106
+ async after() {
107
+ /* ... */
108
+ },
109
+ },
110
+ };
111
+ ```
112
+
113
+ ### Storybook parameters
114
+
115
+ Also you could define parameters on `global`, `kind` or `story` levels. All these parameters are deeply merged by Storybook for each story. But bear in mind when you define skip option as an array Storybook treats it as primitive value and doesn't merge with other skip options.
116
+
117
+ ```tsx
118
+ // .storybook/preview.tsx
119
+ export const parameters = {
120
+ creevey: {
121
+ // Skip all *hover tests in IE11 on the global level
122
+ skip: {
123
+ ie11: { in: 'ie11', tests: /.*hover$/ },
124
+ },
125
+ },
126
+ };
127
+ ```
128
+
129
+ ```tsx
130
+ import React from 'react';
131
+ import { Meta, Story } from '@storybook/react';
132
+ import { CreeveyMeta, CreeveyStory } from 'creevey';
133
+ import MyComponent from './src/components/MyComponent';
134
+
135
+ export default {
136
+ title: 'MyComponent'
137
+ parameters: {
138
+ creevey: {
139
+ // You could skip some browsers/stories or even specific tests
140
+ skip: [
141
+ { in: 'ie11', reason: "`MyComponent` doesn't support ie11" },
142
+ { in: 'firefox', stories: 'Loading', reason: "Loading stories are flaky in firefox" },
143
+ {
144
+ in: ['firefox', 'chrome'],
145
+ tests: /.*hover$/,
146
+ reason: "For some reason `MyComponent` hovering doesn't work correctly",
147
+ },
148
+ ],
149
+ },
150
+ },
151
+ } as Meta & CreeveyMeta;
152
+
153
+ export const Basic: Story & CreeveyStory = () => <MyComponent />;
154
+ Basic.parameters = {
155
+ creevey: {
156
+ captureElement: '.container',
157
+ // elements to ignore in capturing screenshot
158
+ ignoreElements: ['button', '.local-time'],
159
+ // Delay before test starts in ms
160
+ delay: 1000,
161
+ tests: {
162
+ /* ... */
163
+ },
164
+ },
165
+ };
166
+ ```
167
+
168
+ ### `skip` option examples:
169
+
170
+ ```ts
171
+ interface SkipOption {
172
+ reason?: string;
173
+ in?: string | string[] | RegExp;
174
+ kinds?: string | string[] | RegExp;
175
+ stories?: string | string[] | RegExp;
176
+ tests?: string | string[] | RegExp;
177
+ }
178
+
179
+ type SkipOptions = SkipOption | SkipOption[] | Record<string, SkipOption | SkipOption[]>;
180
+ ```
181
+
182
+ - Skip all stories for all browsers:
183
+ - `skip: true`
184
+ - `skip: 'Skip reason message'`
185
+ - `skip: { reason: 'Skip reason message' }`
186
+ - Skip all stories for specific browsers:
187
+ - `skip: { in: 'ie11' }`
188
+ - `skip: { in: ['ie11', 'chrome'] }`
189
+ - `skip: { in: /^fire.*/ }`
190
+ - Skip all stories in specific kinds:
191
+ - `skip: { kinds: 'Button' }`
192
+ - `skip: { kinds: ['Button', 'Input'] }`
193
+ - `skip: { kinds: /.*Modal$/ }`
194
+ - Skip all tests in specific stories:
195
+ - `skip: { stories: 'simple' }`
196
+ - `skip: { stories: ['simple', 'special'] }`
197
+ - `skip: { stories: /.*large$/ }`
198
+ - Skip specific tests:
199
+ - `skip: { tests: 'click' }`
200
+ - `skip: { tests: ['hover', 'click'] }`
201
+ - `skip: { tests: /^press.*$/ }`
202
+ - Multiple skip options:
203
+ - as an array `skip: [{ /* ... */ }]`
204
+ - as an object
205
+ ```
206
+ skip: {
207
+ foo: { /* ... */ },
208
+ bar: { /* ... */ },
209
+ }
210
+ ```
211
+
212
+ NOTE: If you try to skip stories by story name, the storybook name format will be used (For more info see [storybook-export-vs-name-handling](https://storybook.js.org/docs/formats/component-story-format/#storybook-export-vs-name-handling))
package/docs/grid.md CHANGED
@@ -1,10 +1,10 @@
1
- ## Use your Selenium Grid (BrowserStack/SauceLabs/etc)
2
-
3
- Sometimes you already have Selenium Grid on one of many different e2e testing services, like LambdaTest, BrowserStack, or SauceLabs , or use a self-hosted one. You could use these services. If your Selenium Grid is located in the same network where you going to start Creevey, you will need to define `gridUrl` parameter in Creevey config. Overwise you need to start tunneling tool depending on what Grid you use:
4
-
5
- - [LambdaTest] (https://www.npmjs.com/package/@lambdatest/node-tunnel)
6
- - [browserstack-local](https://www.npmjs.com/package/browserstack-local)
7
- - [sauce-connect-launcher](https://www.npmjs.com/package/sauce-connect-launcher)
8
- - [open-ssh-tunnel](https://www.npmjs.com/package/open-ssh-tunnel)
9
-
10
- To start one of these tool use `before/after` hook parameters in Creevey config.
1
+ ## Use your Selenium Grid (BrowserStack/SauceLabs/etc)
2
+
3
+ Sometimes you already have Selenium Grid on one of many different e2e testing services, like LambdaTest, BrowserStack, or SauceLabs , or use a self-hosted one. You could use these services. If your Selenium Grid is located in the same network where you going to start Creevey, you will need to define `gridUrl` parameter in Creevey config. Overwise you need to start tunneling tool depending on what Grid you use:
4
+
5
+ - [LambdaTest] (https://www.npmjs.com/package/@lambdatest/node-tunnel)
6
+ - [browserstack-local](https://www.npmjs.com/package/browserstack-local)
7
+ - [sauce-connect-launcher](https://www.npmjs.com/package/sauce-connect-launcher)
8
+ - [open-ssh-tunnel](https://www.npmjs.com/package/open-ssh-tunnel)
9
+
10
+ To start one of these tool use `before/after` hook parameters in Creevey config.
package/docs/tests.md CHANGED
@@ -1,63 +1,63 @@
1
- ## Write tests
2
-
3
- By default Creevey generate for each story very simple screenshot test. In most cases it would be enough to test your UI. But you may want to do some interactions and capture one or multiple screenshots with different states of your story. For this case you could write custom tests, like this
4
-
5
- ```tsx
6
- import React from 'react';
7
- import { Story } from '@storybook/react';
8
- import { CreeveyStory } from 'creevey';
9
- import MyComponent from './src/components/MyComponent';
10
-
11
- export default { title: 'MyComponent' };
12
-
13
- export const Basic: Story & CreeveyStory = () => <MyComponent />;
14
- Basic.parameters = {
15
- creevey: {
16
- captureElement: '#root',
17
- tests: {
18
- async click() {
19
- await this.browser.actions().click(this.captureElement).perform();
20
-
21
- await this.expect(await this.takeScreenshot()).to.matchImage('clicked component');
22
- },
23
- },
24
- },
25
- };
26
- ```
27
-
28
- NOTE: Here you define story parameters with simple test `click`. Where you setup capturing element `#root` then click on that element and taking screenshot to assert it. `this.browser` allow you to access to native selenium webdriver instance you could check [API here](https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html).
29
-
30
- You also could write more powerful tests with asserting multiple screenshots
31
-
32
- ```tsx
33
- import React from 'react';
34
- import { CSFStory } from 'creevey';
35
- import MyForm from './src/components/MyForm';
36
-
37
- export default { title: 'MyForm' };
38
-
39
- export const Basic: CSFStory<JSX.Element> = () => <MyForm />;
40
- Basic.story = {
41
- parameters: {
42
- creevey: {
43
- captureElement: '#root',
44
- delay: 1000,
45
- tests: {
46
- async submit() {
47
- const input = await this.browser.findElement({ css: '.my-input' });
48
-
49
- const empty = await this.takeScreenshot();
50
-
51
- await this.browser.actions().click(input).sendKeys('Hello Creevey').sendKeys(this.keys.ENTER).perform();
52
-
53
- const submitted = await this.takeScreenshot();
54
-
55
- await this.expect({ empty, submitted }).to.matchImages();
56
- },
57
- },
58
- },
59
- },
60
- };
61
- ```
62
-
63
- NOTE: In this example I fill some simple form and submit it. Also as you could see, I taking two different screenshots `empty` and `submitted` and assert these in the end.
1
+ ## Write tests
2
+
3
+ By default Creevey generate for each story very simple screenshot test. In most cases it would be enough to test your UI. But you may want to do some interactions and capture one or multiple screenshots with different states of your story. For this case you could write custom tests, like this
4
+
5
+ ```tsx
6
+ import React from 'react';
7
+ import { Story } from '@storybook/react';
8
+ import { CreeveyStory } from 'creevey';
9
+ import MyComponent from './src/components/MyComponent';
10
+
11
+ export default { title: 'MyComponent' };
12
+
13
+ export const Basic: Story & CreeveyStory = () => <MyComponent />;
14
+ Basic.parameters = {
15
+ creevey: {
16
+ captureElement: '#root',
17
+ tests: {
18
+ async click() {
19
+ await this.browser.actions().click(this.captureElement).perform();
20
+
21
+ await this.expect(await this.takeScreenshot()).to.matchImage('clicked component');
22
+ },
23
+ },
24
+ },
25
+ };
26
+ ```
27
+
28
+ NOTE: Here you define story parameters with simple test `click`. Where you setup capturing element `#root` then click on that element and taking screenshot to assert it. `this.browser` allow you to access to native selenium webdriver instance you could check [API here](https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html).
29
+
30
+ You also could write more powerful tests with asserting multiple screenshots
31
+
32
+ ```tsx
33
+ import React from 'react';
34
+ import { CSFStory } from 'creevey';
35
+ import MyForm from './src/components/MyForm';
36
+
37
+ export default { title: 'MyForm' };
38
+
39
+ export const Basic: CSFStory<JSX.Element> = () => <MyForm />;
40
+ Basic.story = {
41
+ parameters: {
42
+ creevey: {
43
+ captureElement: '#root',
44
+ delay: 1000,
45
+ tests: {
46
+ async submit() {
47
+ const input = await this.browser.findElement({ css: '.my-input' });
48
+
49
+ const empty = await this.takeScreenshot();
50
+
51
+ await this.browser.actions().click(input).sendKeys('Hello Creevey').sendKeys(this.keys.ENTER).perform();
52
+
53
+ const submitted = await this.takeScreenshot();
54
+
55
+ await this.expect({ empty, submitted }).to.matchImages();
56
+ },
57
+ },
58
+ },
59
+ },
60
+ };
61
+ ```
62
+
63
+ NOTE: In this example I fill some simple form and submit it. Also as you could see, I taking two different screenshots `empty` and `submitted` and assert these in the end.
package/jest.config.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ moduleNameMapper: {
3
+ '#(.*)': '<rootDir>/node_modules/$1',
4
+ },
5
+ transformIgnorePatterns: [],
6
+ };