creevey 0.9.0-non-webpack.2 → 0.9.0-non-webpack.2.fix-capture-element
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.
- package/AUTHORS +15 -15
- package/CHANGELOG.md +1275 -1275
- package/LICENSE +21 -21
- package/docs/config.md +212 -212
- package/docs/grid.md +10 -10
- package/docs/tests.md +63 -63
- package/lib/cjs/client/addon/components/Icons.js +1 -1
- package/lib/cjs/client/addon/withCreevey.js +39 -44
- package/lib/cjs/client/shared/helpers.js +4 -4
- package/lib/cjs/client/web/32.js +1 -1
- package/lib/cjs/client/web/551.js +1 -1
- package/lib/cjs/client/web/691.js +1 -1
- package/lib/cjs/client/web/725.js +1 -1
- package/lib/cjs/client/web/index.html +19 -19
- package/lib/cjs/client/web/main.js +1 -1
- package/lib/esm/client/addon/components/Icons.js +1 -1
- package/lib/esm/client/addon/withCreevey.js +41 -44
- package/lib/esm/client/shared/helpers.js +4 -4
- package/package.json +1 -1
- package/types/babel__register.d.ts +1 -1
- package/types/chai.d.ts +12 -12
- package/types/event-source-polyfill.d.ts +6 -6
- package/types/mocha.d.ts +20 -20
- package/types/png.d.ts +4 -4
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/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.
|
@@ -39,7 +39,7 @@ const ForwardIcon = _ref2 => {
|
|
39
39
|
viewBox: "0 0 512 512"
|
40
40
|
}, /*#__PURE__*/_react.default.createElement("path", {
|
41
41
|
fill: "currentColor",
|
42
|
-
d: "M460.9,246.8l-209-164.2c-7.8-6.1-19.2-0.6-19.2,9.2v328.4c0,9.8,11.4,15.3,19.2,9.2l209-164.2c5.1-4,6-11.4,2-16.5
|
42
|
+
d: "M460.9,246.8l-209-164.2c-7.8-6.1-19.2-0.6-19.2,9.2v328.4c0,9.8,11.4,15.3,19.2,9.2l209-164.2c5.1-4,6-11.4,2-16.5 C462.4,248,461.7,247.3,460.9,246.8L460.9,246.8z M228.2,246.8L19.2,82.5C11.4,76.4,0,82,0,91.8v328.4c0,9.8,11.4,15.3,19.2,9.2 l209-164.2c3-2.3,4.5-5.8,4.5-9.2C232.7,252.6,231.2,249.1,228.2,246.8z M507.3,64h-37.2c-2.5,0-4.7,2-4.7,4.4v375.3 c0,2.4,2.1,4.4,4.7,4.4h37.2c2.5,0,4.7-2,4.7-4.4V68.4C512,66,509.9,64,507.3,64z"
|
43
43
|
}));
|
44
44
|
};
|
45
45
|
|