creevey 0.8.1-beta.0 → 0.8.1-sb7.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.
- package/CHANGELOG.md +8 -0
- package/package.json +22 -19
- package/lib/cjs/cli.js +0 -5
- package/lib/cjs/client/addon/Manager.js +0 -264
- package/lib/cjs/client/addon/components/Addon.js +0 -55
- package/lib/cjs/client/addon/components/Icons.js +0 -46
- package/lib/cjs/client/addon/components/Panel.js +0 -72
- package/lib/cjs/client/addon/components/TestSelect.js +0 -65
- package/lib/cjs/client/addon/components/Tools.js +0 -95
- package/lib/cjs/client/addon/decorator.js +0 -11
- package/lib/cjs/client/addon/index.js +0 -31
- package/lib/cjs/client/addon/preset.ie11.js +0 -74
- package/lib/cjs/client/addon/preset.js +0 -62
- package/lib/cjs/client/addon/readyForCapture.js +0 -12
- package/lib/cjs/client/addon/register.js +0 -72
- package/lib/cjs/client/addon/utils.js +0 -42
- package/lib/cjs/client/addon/withCreevey.js +0 -350
- package/lib/cjs/client/shared/components/ImagesView/BlendView.js +0 -87
- package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +0 -92
- package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +0 -154
- package/lib/cjs/client/shared/components/ImagesView/SlideView.js +0 -166
- package/lib/cjs/client/shared/components/ImagesView/SwapView.js +0 -91
- package/lib/cjs/client/shared/components/ImagesView/index.js +0 -45
- package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +0 -50
- package/lib/cjs/client/shared/components/PageFooter/Paging.js +0 -94
- package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +0 -82
- package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +0 -119
- package/lib/cjs/client/shared/components/ResultsPage.js +0 -143
- package/lib/cjs/client/shared/creeveyClientApi.js +0 -76
- package/lib/cjs/client/shared/helpers.js +0 -411
- package/lib/cjs/client/shared/viewMode.js +0 -17
- package/lib/cjs/client/web/142.js +0 -2
- package/lib/cjs/client/web/142.js.LICENSE.txt +0 -12
- package/lib/cjs/client/web/32.js +0 -1
- package/lib/cjs/client/web/551.js +0 -1
- package/lib/cjs/client/web/566.js +0 -2
- package/lib/cjs/client/web/566.js.LICENSE.txt +0 -31
- package/lib/cjs/client/web/691.js +0 -2
- package/lib/cjs/client/web/691.js.LICENSE.txt +0 -8
- package/lib/cjs/client/web/725.js +0 -1
- package/lib/cjs/client/web/index.html +0 -19
- package/lib/cjs/client/web/main.js +0 -2
- package/lib/cjs/client/web/main.js.LICENSE.txt +0 -49
- package/lib/cjs/creevey.js +0 -69
- package/lib/cjs/index.js +0 -39
- package/lib/cjs/server/config.js +0 -93
- package/lib/cjs/server/docker.js +0 -146
- package/lib/cjs/server/extract.js +0 -46
- package/lib/cjs/server/index.js +0 -83
- package/lib/cjs/server/loaders/babel/creevey-plugin.js +0 -86
- package/lib/cjs/server/loaders/babel/helpers.js +0 -469
- package/lib/cjs/server/loaders/babel/register.js +0 -124
- package/lib/cjs/server/loaders/hooks/mdx.js +0 -30
- package/lib/cjs/server/loaders/hooks/svelte.js +0 -65
- package/lib/cjs/server/loaders/webpack/compile.js +0 -269
- package/lib/cjs/server/loaders/webpack/creevey-loader.js +0 -172
- package/lib/cjs/server/loaders/webpack/dummy-hmr.js +0 -39
- package/lib/cjs/server/loaders/webpack/mdx-loader.js +0 -72
- package/lib/cjs/server/loaders/webpack/start.js +0 -41
- package/lib/cjs/server/logger.js +0 -48
- package/lib/cjs/server/master/api.js +0 -71
- package/lib/cjs/server/master/index.js +0 -152
- package/lib/cjs/server/master/master.js +0 -57
- package/lib/cjs/server/master/pool.js +0 -197
- package/lib/cjs/server/master/runner.js +0 -281
- package/lib/cjs/server/master/server.js +0 -131
- package/lib/cjs/server/messages.js +0 -264
- package/lib/cjs/server/selenium/browser.js +0 -656
- package/lib/cjs/server/selenium/index.js +0 -31
- package/lib/cjs/server/selenium/selenoid.js +0 -172
- package/lib/cjs/server/stories.js +0 -153
- package/lib/cjs/server/storybook/entry.js +0 -53
- package/lib/cjs/server/storybook/helpers.js +0 -158
- package/lib/cjs/server/storybook/providers/browser.js +0 -74
- package/lib/cjs/server/storybook/providers/nodejs.js +0 -237
- package/lib/cjs/server/update.js +0 -79
- package/lib/cjs/server/utils.js +0 -169
- package/lib/cjs/server/worker/chai-image.js +0 -142
- package/lib/cjs/server/worker/helpers.js +0 -69
- package/lib/cjs/server/worker/index.js +0 -15
- package/lib/cjs/server/worker/reporter.js +0 -108
- package/lib/cjs/server/worker/worker.js +0 -268
- package/lib/cjs/shared/index.js +0 -101
- package/lib/cjs/shared/serializeRegExp.js +0 -42
- package/lib/cjs/types.js +0 -74
- package/lib/esm/cli.js +0 -4
- package/lib/esm/client/addon/Manager.js +0 -248
- package/lib/esm/client/addon/components/Addon.js +0 -39
- package/lib/esm/client/addon/components/Icons.js +0 -31
- package/lib/esm/client/addon/components/Panel.js +0 -53
- package/lib/esm/client/addon/components/TestSelect.js +0 -51
- package/lib/esm/client/addon/components/Tools.js +0 -74
- package/lib/esm/client/addon/decorator.js +0 -2
- package/lib/esm/client/addon/index.js +0 -2
- package/lib/esm/client/addon/preset.ie11.js +0 -59
- package/lib/esm/client/addon/preset.js +0 -41
- package/lib/esm/client/addon/readyForCapture.js +0 -5
- package/lib/esm/client/addon/register.js +0 -51
- package/lib/esm/client/addon/utils.js +0 -32
- package/lib/esm/client/addon/withCreevey.js +0 -323
- package/lib/esm/client/shared/components/ImagesView/BlendView.js +0 -67
- package/lib/esm/client/shared/components/ImagesView/ImagesView.js +0 -69
- package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +0 -131
- package/lib/esm/client/shared/components/ImagesView/SlideView.js +0 -143
- package/lib/esm/client/shared/components/ImagesView/SwapView.js +0 -71
- package/lib/esm/client/shared/components/ImagesView/index.js +0 -5
- package/lib/esm/client/shared/components/PageFooter/PageFooter.js +0 -36
- package/lib/esm/client/shared/components/PageFooter/Paging.js +0 -80
- package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +0 -68
- package/lib/esm/client/shared/components/PageHeader/PageHeader.js +0 -97
- package/lib/esm/client/shared/components/ResultsPage.js +0 -115
- package/lib/esm/client/shared/creeveyClientApi.js +0 -67
- package/lib/esm/client/shared/helpers.js +0 -353
- package/lib/esm/client/shared/viewMode.js +0 -6
- package/lib/esm/creevey.js +0 -54
- package/lib/esm/index.js +0 -3
- package/lib/esm/server/config.js +0 -70
- package/lib/esm/server/docker.js +0 -123
- package/lib/esm/server/extract.js +0 -32
- package/lib/esm/server/index.js +0 -64
- package/lib/esm/server/loaders/babel/creevey-plugin.js +0 -72
- package/lib/esm/server/loaders/babel/helpers.js +0 -452
- package/lib/esm/server/loaders/babel/register.js +0 -103
- package/lib/esm/server/loaders/hooks/mdx.js +0 -15
- package/lib/esm/server/loaders/hooks/svelte.js +0 -49
- package/lib/esm/server/loaders/webpack/compile.js +0 -246
- package/lib/esm/server/loaders/webpack/creevey-loader.js +0 -152
- package/lib/esm/server/loaders/webpack/dummy-hmr.js +0 -32
- package/lib/esm/server/loaders/webpack/mdx-loader.js +0 -58
- package/lib/esm/server/loaders/webpack/start.js +0 -27
- package/lib/esm/server/logger.js +0 -20
- package/lib/esm/server/master/api.js +0 -60
- package/lib/esm/server/master/index.js +0 -131
- package/lib/esm/server/master/master.js +0 -38
- package/lib/esm/server/master/pool.js +0 -176
- package/lib/esm/server/master/runner.js +0 -259
- package/lib/esm/server/master/server.js +0 -107
- package/lib/esm/server/messages.js +0 -232
- package/lib/esm/server/selenium/browser.js +0 -623
- package/lib/esm/server/selenium/index.js +0 -2
- package/lib/esm/server/selenium/selenoid.js +0 -149
- package/lib/esm/server/stories.js +0 -135
- package/lib/esm/server/storybook/entry.js +0 -27
- package/lib/esm/server/storybook/helpers.js +0 -97
- package/lib/esm/server/storybook/providers/browser.js +0 -60
- package/lib/esm/server/storybook/providers/nodejs.js +0 -216
- package/lib/esm/server/update.js +0 -61
- package/lib/esm/server/utils.js +0 -128
- package/lib/esm/server/worker/chai-image.js +0 -130
- package/lib/esm/server/worker/helpers.js +0 -60
- package/lib/esm/server/worker/index.js +0 -1
- package/lib/esm/server/worker/reporter.js +0 -86
- package/lib/esm/server/worker/worker.js +0 -238
- package/lib/esm/shared/index.js +0 -78
- package/lib/esm/shared/serializeRegExp.js +0 -24
- package/lib/esm/types.js +0 -43
- package/lib/types/cli.d.ts +0 -1
- package/lib/types/client/addon/Manager.d.ts +0 -37
- package/lib/types/client/addon/components/Addon.d.ts +0 -8
- package/lib/types/client/addon/components/Icons.d.ts +0 -7
- package/lib/types/client/addon/components/Panel.d.ts +0 -9
- package/lib/types/client/addon/components/TestSelect.d.ts +0 -8
- package/lib/types/client/addon/components/Tools.d.ts +0 -6
- package/lib/types/client/addon/decorator.d.ts +0 -1
- package/lib/types/client/addon/index.d.ts +0 -2
- package/lib/types/client/addon/preset.d.ts +0 -23
- package/lib/types/client/addon/preset.ie11.d.ts +0 -10
- package/lib/types/client/addon/readyForCapture.d.ts +0 -6
- package/lib/types/client/addon/register.d.ts +0 -3
- package/lib/types/client/addon/utils.d.ts +0 -3
- package/lib/types/client/addon/withCreevey.d.ts +0 -24
- package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +0 -3
- package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +0 -24
- package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +0 -3
- package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +0 -3
- package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +0 -3
- package/lib/types/client/shared/components/ImagesView/index.d.ts +0 -5
- package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +0 -8
- package/lib/types/client/shared/components/PageFooter/Paging.d.ts +0 -7
- package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +0 -12
- package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +0 -16
- package/lib/types/client/shared/components/ResultsPage.d.ts +0 -18
- package/lib/types/client/shared/creeveyClientApi.d.ts +0 -9
- package/lib/types/client/shared/helpers.d.ts +0 -46
- package/lib/types/client/shared/viewMode.d.ts +0 -4
- package/lib/types/client/web/CreeveyApp.d.ts +0 -11
- package/lib/types/client/web/CreeveyContext.d.ts +0 -11
- package/lib/types/client/web/CreeveyLoader.d.ts +0 -2
- package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +0 -19
- package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +0 -6
- package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +0 -14
- package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +0 -12
- package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +0 -33
- package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +0 -7
- package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +0 -10
- package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +0 -9
- package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +0 -6
- package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +0 -1
- package/lib/types/client/web/KeyboardEventsContext.d.ts +0 -13
- package/lib/types/client/web/index.d.ts +0 -4
- package/lib/types/creevey.d.ts +0 -1
- package/lib/types/index.d.ts +0 -2
- package/lib/types/server/config.d.ts +0 -4
- package/lib/types/server/docker.d.ts +0 -7
- package/lib/types/server/extract.d.ts +0 -2
- package/lib/types/server/index.d.ts +0 -2
- package/lib/types/server/loaders/babel/creevey-plugin.d.ts +0 -1
- package/lib/types/server/loaders/babel/helpers.d.ts +0 -19
- package/lib/types/server/loaders/babel/register.d.ts +0 -5
- package/lib/types/server/loaders/hooks/mdx.d.ts +0 -1
- package/lib/types/server/loaders/hooks/svelte.d.ts +0 -1
- package/lib/types/server/loaders/webpack/compile.d.ts +0 -2
- package/lib/types/server/loaders/webpack/creevey-loader.d.ts +0 -4
- package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +0 -10
- package/lib/types/server/loaders/webpack/mdx-loader.d.ts +0 -6
- package/lib/types/server/loaders/webpack/start.d.ts +0 -1
- package/lib/types/server/logger.d.ts +0 -10
- package/lib/types/server/master/api.d.ts +0 -7
- package/lib/types/server/master/index.d.ts +0 -3
- package/lib/types/server/master/master.d.ts +0 -7
- package/lib/types/server/master/pool.d.ts +0 -31
- package/lib/types/server/master/runner.d.ts +0 -26
- package/lib/types/server/master/server.d.ts +0 -2
- package/lib/types/server/messages.d.ts +0 -29
- package/lib/types/server/selenium/browser.d.ts +0 -17
- package/lib/types/server/selenium/index.d.ts +0 -2
- package/lib/types/server/selenium/selenoid.d.ts +0 -3
- package/lib/types/server/stories.d.ts +0 -8
- package/lib/types/server/storybook/entry.d.ts +0 -17
- package/lib/types/server/storybook/helpers.d.ts +0 -24
- package/lib/types/server/storybook/providers/browser.d.ts +0 -4
- package/lib/types/server/storybook/providers/nodejs.d.ts +0 -9
- package/lib/types/server/update.d.ts +0 -2
- package/lib/types/server/utils.d.ts +0 -23
- package/lib/types/server/worker/chai-image.d.ts +0 -6
- package/lib/types/server/worker/helpers.d.ts +0 -8
- package/lib/types/server/worker/index.d.ts +0 -1
- package/lib/types/server/worker/reporter.d.ts +0 -8
- package/lib/types/server/worker/worker.d.ts +0 -4
- package/lib/types/shared/index.d.ts +0 -7
- package/lib/types/shared/serializeRegExp.d.ts +0 -9
- package/lib/types/types.d.ts +0 -486
@@ -1,238 +0,0 @@
|
|
1
|
-
import { promisify } from 'util';
|
2
|
-
import fs from 'fs';
|
3
|
-
import path from 'path';
|
4
|
-
import chai from 'chai';
|
5
|
-
import chalk from 'chalk';
|
6
|
-
import Mocha from 'mocha';
|
7
|
-
import { Key, until } from 'selenium-webdriver';
|
8
|
-
import { isImageError } from '../../types';
|
9
|
-
import { subscribeOn, emitTestMessage, emitWorkerMessage } from '../messages';
|
10
|
-
import chaiImage from './chai-image';
|
11
|
-
import { closeBrowser, getBrowser, switchStory } from '../selenium';
|
12
|
-
import { CreeveyReporter, TeamcityReporter } from './reporter';
|
13
|
-
import { addTestsFromStories } from './helpers';
|
14
|
-
import { logger } from '../logger';
|
15
|
-
const statAsync = promisify(fs.stat);
|
16
|
-
const readdirAsync = promisify(fs.readdir);
|
17
|
-
const readFileAsync = promisify(fs.readFile);
|
18
|
-
const writeFileAsync = promisify(fs.writeFile);
|
19
|
-
const mkdirAsync = promisify(fs.mkdir);
|
20
|
-
|
21
|
-
async function getStat(filePath) {
|
22
|
-
try {
|
23
|
-
return await statAsync(filePath);
|
24
|
-
} catch (error) {
|
25
|
-
if (typeof error == 'object' && error && error.code === 'ENOENT') {
|
26
|
-
return null;
|
27
|
-
}
|
28
|
-
|
29
|
-
throw error;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
async function getLastImageNumber(imageDir, imageName) {
|
34
|
-
const actualImagesRegexp = new RegExp(`${imageName}-actual-(\\d+)\\.png`);
|
35
|
-
|
36
|
-
try {
|
37
|
-
return (await readdirAsync(imageDir)).map(filename => filename.replace(actualImagesRegexp, '$1')).map(Number).filter(x => !isNaN(x)).sort((a, b) => b - a)[0] ?? 0;
|
38
|
-
} catch (_error) {
|
39
|
-
return 0;
|
40
|
-
}
|
41
|
-
} // FIXME browser options hotfix
|
42
|
-
|
43
|
-
|
44
|
-
export default async function worker(config, options) {
|
45
|
-
var _await$browser$getSes;
|
46
|
-
|
47
|
-
let retries = 0;
|
48
|
-
let images = {};
|
49
|
-
let error = undefined;
|
50
|
-
const screenshots = [];
|
51
|
-
const testScope = [];
|
52
|
-
|
53
|
-
function runHandler(failures) {
|
54
|
-
if (failures > 0 && (error || Object.values(images).some(image => (image === null || image === void 0 ? void 0 : image.error) != null))) {
|
55
|
-
const isTimeout = hasTimeout(error) || Object.values(images).some(image => hasTimeout(image === null || image === void 0 ? void 0 : image.error));
|
56
|
-
const payload = {
|
57
|
-
status: 'failed',
|
58
|
-
images,
|
59
|
-
error
|
60
|
-
};
|
61
|
-
isTimeout ? emitWorkerMessage({
|
62
|
-
type: 'error',
|
63
|
-
payload: {
|
64
|
-
error: error ?? 'Unknown error'
|
65
|
-
}
|
66
|
-
}) : emitTestMessage({
|
67
|
-
type: 'end',
|
68
|
-
payload
|
69
|
-
});
|
70
|
-
} else {
|
71
|
-
emitTestMessage({
|
72
|
-
type: 'end',
|
73
|
-
payload: {
|
74
|
-
status: 'success',
|
75
|
-
images
|
76
|
-
}
|
77
|
-
});
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
async function saveImages(imageDir, images) {
|
82
|
-
await mkdirAsync(imageDir, {
|
83
|
-
recursive: true
|
84
|
-
});
|
85
|
-
|
86
|
-
for (const {
|
87
|
-
name,
|
88
|
-
data
|
89
|
-
} of images) {
|
90
|
-
await writeFileAsync(path.join(imageDir, name), data);
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
async function getExpected(assertImageName) {
|
95
|
-
// context => [kind, story, test, browser]
|
96
|
-
// rootSuite -> kindSuite -> storyTest -> [browsers.png]
|
97
|
-
// rootSuite -> kindSuite -> storySuite -> test -> [browsers.png]
|
98
|
-
const testPath = [...testScope];
|
99
|
-
const imageName = assertImageName ?? testPath.pop();
|
100
|
-
const imagesMeta = [];
|
101
|
-
const reportImageDir = path.join(config.reportDir, ...testPath);
|
102
|
-
const imageNumber = (await getLastImageNumber(reportImageDir, imageName)) + 1;
|
103
|
-
const actualImageName = `${imageName}-actual-${imageNumber}.png`;
|
104
|
-
const image = images[imageName] = images[imageName] ?? {
|
105
|
-
actual: actualImageName
|
106
|
-
};
|
107
|
-
|
108
|
-
const onCompare = async (actual, expect, diff) => {
|
109
|
-
imagesMeta.push({
|
110
|
-
name: image.actual,
|
111
|
-
data: actual
|
112
|
-
});
|
113
|
-
|
114
|
-
if (diff && expect) {
|
115
|
-
image.expect = `${imageName}-expect-${imageNumber}.png`;
|
116
|
-
image.diff = `${imageName}-diff-${imageNumber}.png`;
|
117
|
-
imagesMeta.push({
|
118
|
-
name: image.expect,
|
119
|
-
data: expect
|
120
|
-
});
|
121
|
-
imagesMeta.push({
|
122
|
-
name: image.diff,
|
123
|
-
data: diff
|
124
|
-
});
|
125
|
-
}
|
126
|
-
|
127
|
-
if (options.saveReport) {
|
128
|
-
await saveImages(reportImageDir, imagesMeta);
|
129
|
-
}
|
130
|
-
};
|
131
|
-
|
132
|
-
const expectImageDir = path.join(config.screenDir, ...testPath);
|
133
|
-
const expectImageStat = await getStat(path.join(expectImageDir, `${imageName}.png`));
|
134
|
-
if (!expectImageStat) return {
|
135
|
-
expected: null,
|
136
|
-
onCompare
|
137
|
-
};
|
138
|
-
const expected = await readFileAsync(path.join(expectImageDir, `${imageName}.png`));
|
139
|
-
return {
|
140
|
-
expected,
|
141
|
-
onCompare
|
142
|
-
};
|
143
|
-
}
|
144
|
-
|
145
|
-
const mochaOptions = {
|
146
|
-
timeout: 30000,
|
147
|
-
reporter: process.env.TEAMCITY_VERSION ? TeamcityReporter : options.reporter || CreeveyReporter,
|
148
|
-
reporterOptions: {
|
149
|
-
reportDir: config.reportDir,
|
150
|
-
topLevelSuite: options.browser,
|
151
|
-
|
152
|
-
get willRetry() {
|
153
|
-
return retries < config.maxRetries;
|
154
|
-
},
|
155
|
-
|
156
|
-
get images() {
|
157
|
-
return images;
|
158
|
-
},
|
159
|
-
|
160
|
-
get sessionId() {
|
161
|
-
return sessionId;
|
162
|
-
}
|
163
|
-
|
164
|
-
}
|
165
|
-
};
|
166
|
-
const mocha = new Mocha(mochaOptions);
|
167
|
-
mocha.cleanReferencesAfterRun(false);
|
168
|
-
chai.use(chaiImage(getExpected, config.diffOptions));
|
169
|
-
if ((await getBrowser(config, options.browser)) == null) return;
|
170
|
-
await addTestsFromStories(mocha.suite, config, {
|
171
|
-
browser: options.browser,
|
172
|
-
watch: options.ui,
|
173
|
-
debug: options.debug,
|
174
|
-
port: options.port
|
175
|
-
});
|
176
|
-
|
177
|
-
try {
|
178
|
-
var _await$getBrowser;
|
179
|
-
|
180
|
-
await ((_await$getBrowser = await getBrowser(config, options.browser)) === null || _await$getBrowser === void 0 ? void 0 : _await$getBrowser.getCurrentUrl());
|
181
|
-
} catch (_) {
|
182
|
-
await closeBrowser();
|
183
|
-
}
|
184
|
-
|
185
|
-
const browser = await getBrowser(config, options.browser);
|
186
|
-
const sessionId = (_await$browser$getSes = await (browser === null || browser === void 0 ? void 0 : browser.getSession())) === null || _await$browser$getSes === void 0 ? void 0 : _await$browser$getSes.getId();
|
187
|
-
if (browser == null) return;
|
188
|
-
const interval = setInterval(() => void browser.getCurrentUrl().then(url => {
|
189
|
-
if (options.debug) logger.debug(`${options.browser}:${chalk.gray(sessionId)}`, 'current url', chalk.magenta(url));
|
190
|
-
}), 10 * 1000);
|
191
|
-
subscribeOn('shutdown', () => clearInterval(interval));
|
192
|
-
mocha.suite.beforeAll(function () {
|
193
|
-
this.config = config;
|
194
|
-
this.browser = browser;
|
195
|
-
this.until = until;
|
196
|
-
this.keys = Key;
|
197
|
-
this.expect = chai.expect;
|
198
|
-
this.browserName = options.browser;
|
199
|
-
this.testScope = testScope;
|
200
|
-
this.screenshots = screenshots;
|
201
|
-
});
|
202
|
-
mocha.suite.beforeEach(switchStory);
|
203
|
-
subscribeOn('test', message => {
|
204
|
-
if (message.type != 'start') return;
|
205
|
-
const test = message.payload;
|
206
|
-
const testPath = test.path.join(' ').replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&');
|
207
|
-
images = {};
|
208
|
-
error = undefined;
|
209
|
-
retries = test.retries;
|
210
|
-
mocha.grep(new RegExp(`^${testPath}$`));
|
211
|
-
const runner = mocha.run(runHandler); // TODO How handle browser corruption?
|
212
|
-
|
213
|
-
runner.on('fail', (_test, reason) => {
|
214
|
-
if (!(reason instanceof Error)) {
|
215
|
-
error = reason;
|
216
|
-
} else if (!isImageError(reason)) {
|
217
|
-
error = reason.stack ?? reason.message;
|
218
|
-
} else if (typeof reason.images == 'string') {
|
219
|
-
const image = images[testScope.slice(-1)[0]];
|
220
|
-
if (image) image.error = reason.images;
|
221
|
-
} else {
|
222
|
-
const imageErrors = reason.images;
|
223
|
-
Object.keys(imageErrors).forEach(imageName => {
|
224
|
-
const image = images[imageName];
|
225
|
-
if (image) image.error = imageErrors[imageName];
|
226
|
-
});
|
227
|
-
}
|
228
|
-
});
|
229
|
-
});
|
230
|
-
logger.info(`${options.browser}:${chalk.gray(sessionId)} is ready`);
|
231
|
-
emitWorkerMessage({
|
232
|
-
type: 'ready'
|
233
|
-
});
|
234
|
-
}
|
235
|
-
|
236
|
-
function hasTimeout(str) {
|
237
|
-
return str != null && str.toLowerCase().includes('timeout');
|
238
|
-
}
|
package/lib/esm/shared/index.js
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
import { mapValues, mergeWith, cloneDeepWith } from 'lodash';
|
2
|
-
import { deserializeRegExp, isSerializedRegExp, isRegExp, serializeRegExp } from './serializeRegExp'; // NOTE: Copy-paste from storybook/api
|
3
|
-
|
4
|
-
export const combineParameters = function () {
|
5
|
-
for (var _len = arguments.length, parameterSets = new Array(_len), _key = 0; _key < _len; _key++) {
|
6
|
-
parameterSets[_key] = arguments[_key];
|
7
|
-
}
|
8
|
-
|
9
|
-
return (// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
10
|
-
mergeWith({}, ...parameterSets, (_, srcValue) => {
|
11
|
-
// Treat arrays as scalars:
|
12
|
-
if (Array.isArray(srcValue)) return srcValue;
|
13
|
-
return undefined;
|
14
|
-
})
|
15
|
-
);
|
16
|
-
}; // NOTE: Copy-paste from storybook/api
|
17
|
-
|
18
|
-
export const denormalizeStoryParameters = _ref => {
|
19
|
-
let {
|
20
|
-
globalParameters,
|
21
|
-
kindParameters,
|
22
|
-
stories
|
23
|
-
} = _ref;
|
24
|
-
return mapValues(stories, storyData => {
|
25
|
-
var _kindParameters$story;
|
26
|
-
|
27
|
-
return { ...storyData,
|
28
|
-
parameters: combineParameters(globalParameters, (_kindParameters$story = kindParameters[storyData.kind]) !== null && _kindParameters$story !== void 0 ? _kindParameters$story : {}, storyData.parameters)
|
29
|
-
};
|
30
|
-
});
|
31
|
-
};
|
32
|
-
export const serializeRawStories = stories => {
|
33
|
-
return mapValues(stories, storyData => {
|
34
|
-
const creevey = storyData.parameters.creevey;
|
35
|
-
|
36
|
-
if (creevey !== null && creevey !== void 0 && creevey.skip) {
|
37
|
-
return { ...storyData,
|
38
|
-
parameters: { ...storyData.parameters,
|
39
|
-
creevey: { ...creevey,
|
40
|
-
skip: cloneDeepWith(creevey.skip, value => {
|
41
|
-
if (isRegExp(value)) {
|
42
|
-
return serializeRegExp(value);
|
43
|
-
}
|
44
|
-
|
45
|
-
return undefined;
|
46
|
-
})
|
47
|
-
}
|
48
|
-
}
|
49
|
-
};
|
50
|
-
}
|
51
|
-
|
52
|
-
return storyData;
|
53
|
-
});
|
54
|
-
};
|
55
|
-
export const deserializeRawStories = stories => {
|
56
|
-
return mapValues(stories, deserializeStory);
|
57
|
-
};
|
58
|
-
export const deserializeStory = story => {
|
59
|
-
const creevey = story.parameters.creevey;
|
60
|
-
|
61
|
-
if (creevey !== null && creevey !== void 0 && creevey.skip) {
|
62
|
-
return { ...story,
|
63
|
-
parameters: { ...story.parameters,
|
64
|
-
creevey: { ...creevey,
|
65
|
-
skip: cloneDeepWith(creevey.skip, value => {
|
66
|
-
if (isSerializedRegExp(value)) {
|
67
|
-
return deserializeRegExp(value);
|
68
|
-
}
|
69
|
-
|
70
|
-
return undefined;
|
71
|
-
})
|
72
|
-
}
|
73
|
-
}
|
74
|
-
};
|
75
|
-
}
|
76
|
-
|
77
|
-
return story;
|
78
|
-
};
|
@@ -1,24 +0,0 @@
|
|
1
|
-
export const isRegExp = exp => {
|
2
|
-
return exp instanceof RegExp;
|
3
|
-
};
|
4
|
-
export const isSerializedRegExp = exp => {
|
5
|
-
return typeof exp === 'object' && exp !== null && Reflect.get(exp, '__regexp') === true;
|
6
|
-
};
|
7
|
-
export const serializeRegExp = exp => {
|
8
|
-
const {
|
9
|
-
source,
|
10
|
-
flags
|
11
|
-
} = exp;
|
12
|
-
return {
|
13
|
-
__regexp: true,
|
14
|
-
source,
|
15
|
-
flags
|
16
|
-
};
|
17
|
-
};
|
18
|
-
export const deserializeRegExp = _ref => {
|
19
|
-
let {
|
20
|
-
source,
|
21
|
-
flags
|
22
|
-
} = _ref;
|
23
|
-
return new RegExp(source, flags);
|
24
|
-
};
|
package/lib/esm/types.js
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
2
|
-
|
3
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
4
|
-
export function noop() {
|
5
|
-
/* noop */
|
6
|
-
}
|
7
|
-
export function isDefined(value) {
|
8
|
-
return value !== null && value !== undefined;
|
9
|
-
}
|
10
|
-
export function isTest(x) {
|
11
|
-
return isDefined(x) && 'id' in x && 'storyId' in x && typeof x.id == 'string' && typeof x.storyId == 'string';
|
12
|
-
}
|
13
|
-
export function isObject(x) {
|
14
|
-
return typeof x == 'object' && x != null;
|
15
|
-
}
|
16
|
-
export function isString(x) {
|
17
|
-
return typeof x == 'string';
|
18
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
19
|
-
|
20
|
-
export function isFunction(x) {
|
21
|
-
return typeof x == 'function';
|
22
|
-
}
|
23
|
-
export function isImageError(error) {
|
24
|
-
return error instanceof Error && 'images' in error;
|
25
|
-
}
|
26
|
-
export function isProcessMessage(message) {
|
27
|
-
return isObject(message) && 'scope' in message;
|
28
|
-
}
|
29
|
-
export function isWorkerMessage(message) {
|
30
|
-
return isProcessMessage(message) && message.scope == 'worker';
|
31
|
-
}
|
32
|
-
export function isStoriesMessage(message) {
|
33
|
-
return isProcessMessage(message) && message.scope == 'stories';
|
34
|
-
}
|
35
|
-
export function isTestMessage(message) {
|
36
|
-
return isProcessMessage(message) && message.scope == 'test';
|
37
|
-
}
|
38
|
-
export function isWebpackMessage(message) {
|
39
|
-
return isProcessMessage(message) && message.scope == 'webpack';
|
40
|
-
}
|
41
|
-
export function isDockerMessage(message) {
|
42
|
-
return isProcessMessage(message) && message.scope == 'docker';
|
43
|
-
}
|
package/lib/types/cli.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import { API } from '@storybook/api';
|
2
|
-
import { denormalizeStoryParameters } from '../../shared';
|
3
|
-
import { CreeveyStatus, CreeveyUpdate, TestData, TestStatus, StoriesRaw } from '../../types';
|
4
|
-
import { CreeveyClientApi } from '../shared/creeveyClientApi';
|
5
|
-
export declare class CreeveyManager {
|
6
|
-
storybookApi: API;
|
7
|
-
storyId: string;
|
8
|
-
activeBrowser: string;
|
9
|
-
selectedTestId: string;
|
10
|
-
status: CreeveyStatus;
|
11
|
-
creeveyApi: CreeveyClientApi | null;
|
12
|
-
stories: StoriesRaw;
|
13
|
-
updateStatusListeners: Array<(update: CreeveyUpdate) => void>;
|
14
|
-
changeTestListeners: Array<(testId: string) => void>;
|
15
|
-
constructor(storybookApi: API);
|
16
|
-
initAll: () => Promise<void>;
|
17
|
-
onUpdateStatus(listener: (update: CreeveyUpdate) => void): () => void;
|
18
|
-
onChangeTest(listener: (testId: string) => void): () => void;
|
19
|
-
handleCreeveyUpdate: (update: CreeveyUpdate) => void;
|
20
|
-
getCurrentTest: () => TestData | undefined;
|
21
|
-
onStoryRendered: (storyId: string) => void;
|
22
|
-
onStart: () => void;
|
23
|
-
onStop: () => void;
|
24
|
-
onImageApprove: (id: string, retry: number, image: string) => void;
|
25
|
-
onStartAllStoryTests: () => void;
|
26
|
-
onStartAllTests: () => void;
|
27
|
-
onSetStories: (data: Parameters<typeof denormalizeStoryParameters>['0']) => void;
|
28
|
-
setActiveBrowser: (browser: string) => void;
|
29
|
-
setSelectedTestId: (testId: string) => void;
|
30
|
-
getStoryTests: (storyId: string) => TestData[];
|
31
|
-
getBrowsers: () => string[];
|
32
|
-
getTestsByStoryIdAndBrowser: (browser: string) => TestData[];
|
33
|
-
getTabTitle: (browser: string) => string;
|
34
|
-
setPanelsTitle: () => void;
|
35
|
-
addStatusesToSideBar(): Promise<void>;
|
36
|
-
addStatusToStoryName(name: string, status: TestStatus | undefined, skip: string | boolean): string;
|
37
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { TestData } from '../../../types';
|
2
|
-
interface PanelProps {
|
3
|
-
tests: TestData[];
|
4
|
-
selectedTestId: string;
|
5
|
-
onChangeTest: (testId: string) => void;
|
6
|
-
onImageApprove: (id: string, retry: number, image: string) => void;
|
7
|
-
}
|
8
|
-
export declare const Panel: ({ tests, selectedTestId, onChangeTest, onImageApprove }: PanelProps) => JSX.Element;
|
9
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const decorators: import("@storybook/addons").MakeDecoratorResult[];
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import { Configuration } from 'webpack';
|
2
|
-
export declare function config(entry?: string[]): string[];
|
3
|
-
export declare function managerEntries(entry?: string[]): string[];
|
4
|
-
declare global {
|
5
|
-
const __CREEVEY_SERVER_HOST__: string;
|
6
|
-
const __CREEVEY_SERVER_PORT__: number;
|
7
|
-
const __CREEVEY_CLIENT_PORT__: number | null;
|
8
|
-
}
|
9
|
-
export interface CreeveyAddonOptions {
|
10
|
-
creeveyConfigPath?: string;
|
11
|
-
creeveyPreExtract?: string;
|
12
|
-
creeveyHost?: string;
|
13
|
-
creeveyPort?: number;
|
14
|
-
clientPort?: number;
|
15
|
-
configType: string;
|
16
|
-
configDir: string;
|
17
|
-
outputDir: string;
|
18
|
-
skipExtract?: boolean;
|
19
|
-
presets?: {
|
20
|
-
apply: <T>(preset: string) => Promise<T | undefined>;
|
21
|
-
};
|
22
|
-
}
|
23
|
-
export declare function managerWebpack(config: Configuration, options: CreeveyAddonOptions): Promise<Configuration>;
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { Configuration } from 'webpack';
|
2
|
-
import { PluginItem } from '@babel/core';
|
3
|
-
interface BabelOptions {
|
4
|
-
extends: string | null;
|
5
|
-
presets: PluginItem[] | null;
|
6
|
-
}
|
7
|
-
export declare const babel: (config: BabelOptions) => BabelOptions;
|
8
|
-
export declare const managerWebpack: (webpackConfig?: Configuration) => Configuration;
|
9
|
-
export declare const webpack: (webpackConfig?: Configuration) => Configuration;
|
10
|
-
export {};
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import type { PreviewWeb } from '@storybook/preview-web';
|
2
|
-
import type { AnyFramework } from '@storybook/csf';
|
3
|
-
import type { StoryStore } from '@storybook/client-api';
|
4
|
-
import { MakeDecoratorResult, Channel } from '@storybook/addons';
|
5
|
-
import { CaptureOptions, StoriesRaw, StorybookGlobals } from '../../types';
|
6
|
-
declare global {
|
7
|
-
interface Window {
|
8
|
-
__CREEVEY_SERVER_HOST__: string;
|
9
|
-
__CREEVEY_SERVER_PORT__: number;
|
10
|
-
__CREEVEY_WORKER_ID__: number;
|
11
|
-
__CREEVEY_GET_STORIES__: () => Promise<StoriesRaw | void>;
|
12
|
-
__CREEVEY_SELECT_STORY__: (storyId: string, kind: string, name: string, shouldWaitForReady: boolean, callback: (response: [error?: string | null, isCaptureCalled?: boolean]) => void) => Promise<void>;
|
13
|
-
__CREEVEY_UPDATE_GLOBALS__: (globals: StorybookGlobals) => void;
|
14
|
-
__CREEVEY_INSERT_IGNORE_STYLES__: (ignoreElements: string[]) => HTMLStyleElement;
|
15
|
-
__CREEVEY_REMOVE_IGNORE_STYLES__: (ignoreStyles: HTMLStyleElement) => void;
|
16
|
-
__CREEVEY_HAS_PLAY_COMPLETED_YET__: (callback: (isPlayCompleted: boolean) => void) => void;
|
17
|
-
__CREEVEY_SET_READY_FOR_CAPTURE__?: () => void;
|
18
|
-
__STORYBOOK_ADDONS_CHANNEL__: Channel;
|
19
|
-
__STORYBOOK_STORY_STORE__: StoryStore<AnyFramework>;
|
20
|
-
__STORYBOOK_PREVIEW__: PreviewWeb<AnyFramework>;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
export declare function withCreevey(): MakeDecoratorResult;
|
24
|
-
export declare function capture(options?: CaptureOptions): Promise<void>;
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import { Images, ImagesViewMode } from '../../../../types';
|
2
|
-
import { Theme } from '@storybook/theming';
|
3
|
-
export declare const themeBorderColors: {
|
4
|
-
actual: string;
|
5
|
-
expect: string;
|
6
|
-
diff: string;
|
7
|
-
};
|
8
|
-
export declare function getBorderColor(theme: Theme, color: string): string;
|
9
|
-
interface ViewProps {
|
10
|
-
actual: string;
|
11
|
-
diff: string;
|
12
|
-
expect: string;
|
13
|
-
}
|
14
|
-
export interface ViewPropsWithTheme extends ViewProps {
|
15
|
-
theme: Theme;
|
16
|
-
}
|
17
|
-
interface ImagesViewProps {
|
18
|
-
url: string;
|
19
|
-
image: Images;
|
20
|
-
canApprove: boolean;
|
21
|
-
mode: ImagesViewMode;
|
22
|
-
}
|
23
|
-
export declare function ImagesView({ url, image, canApprove, mode }: ImagesViewProps): JSX.Element;
|
24
|
-
export {};
|
@@ -1,8 +0,0 @@
|
|
1
|
-
export interface PageFooterProps {
|
2
|
-
canApprove: boolean;
|
3
|
-
retriesCount: number;
|
4
|
-
retry: number;
|
5
|
-
onRetryChange: (retry: number) => void;
|
6
|
-
onApprove: () => void;
|
7
|
-
}
|
8
|
-
export declare function PageFooter({ canApprove, retriesCount, retry, onRetryChange, onApprove, }: PageFooterProps): JSX.Element;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Theme } from '@storybook/theming';
|
3
|
-
interface ImageSwapProps {
|
4
|
-
url: string;
|
5
|
-
isActive: boolean;
|
6
|
-
onClick: (imageName: string) => void;
|
7
|
-
imageName: string;
|
8
|
-
theme: Theme;
|
9
|
-
error?: boolean;
|
10
|
-
}
|
11
|
-
export declare const ImagePreview: React.FC<import("@storybook/theming").AddOptionalTo<ImageSwapProps, "theme">>;
|
12
|
-
export {};
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import { ImagesViewMode, Images } from '../../../../types';
|
2
|
-
interface PageHeaderProps {
|
3
|
-
title: string[];
|
4
|
-
images?: Partial<{
|
5
|
-
[name: string]: Images;
|
6
|
-
}>;
|
7
|
-
errorMessage?: string | null;
|
8
|
-
showViewModes: boolean;
|
9
|
-
showTitle?: boolean;
|
10
|
-
viewMode: ImagesViewMode;
|
11
|
-
imagesWithError?: string[];
|
12
|
-
onImageChange: (name: string) => void;
|
13
|
-
onViewModeChange: (viewMode: ImagesViewMode) => void;
|
14
|
-
}
|
15
|
-
export declare function PageHeader({ title, images, errorMessage, showViewModes, showTitle, viewMode, imagesWithError, onImageChange, onViewModeChange, }: PageHeaderProps): JSX.Element | null;
|
16
|
-
export {};
|