creevey 0.10.0-beta.23 → 0.10.0-beta.24
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/dist/server/config.js +2 -0
- package/dist/server/config.js.map +1 -1
- package/dist/server/connection.d.ts +4 -0
- package/dist/server/connection.js +35 -0
- package/dist/server/connection.js.map +1 -0
- package/dist/server/index.js +33 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/master/start.js +1 -1
- package/dist/server/master/start.js.map +1 -1
- package/dist/server/playwright/docker-file.js +2 -13
- package/dist/server/playwright/docker-file.js.map +1 -1
- package/dist/server/playwright/internal.d.ts +3 -2
- package/dist/server/playwright/internal.js +49 -32
- package/dist/server/playwright/internal.js.map +1 -1
- package/dist/server/testsFiles/parser.js +44 -2
- package/dist/server/testsFiles/parser.js.map +1 -1
- package/dist/server/utils.d.ts +17 -0
- package/dist/server/utils.js +53 -3
- package/dist/server/utils.js.map +1 -1
- package/dist/types.d.ts +16 -2
- package/dist/types.js.map +1 -1
- package/docs/config.md +3 -0
- package/package.json +4 -4
- package/src/server/config.ts +1 -0
- package/src/server/connection.ts +32 -0
- package/src/server/index.ts +37 -2
- package/src/server/master/start.ts +1 -1
- package/src/server/playwright/docker-file.ts +2 -14
- package/src/server/playwright/internal.ts +48 -34
- package/src/server/testsFiles/parser.ts +51 -1
- package/src/server/utils.ts +59 -3
- package/src/types.ts +16 -2
package/src/server/utils.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import fs from 'fs';
|
2
|
-
import
|
2
|
+
import https from 'https';
|
3
|
+
import http from 'http';
|
3
4
|
import cluster from 'cluster';
|
4
5
|
import { dirname } from 'path';
|
5
6
|
import { fileURLToPath, pathToFileURL } from 'url';
|
@@ -7,6 +8,7 @@ import { register as esmRegister } from 'tsx/esm/api';
|
|
7
8
|
import { register as cjsRegister } from 'tsx/cjs/api';
|
8
9
|
import { SkipOptions, SkipOption, isDefined, TestData, noop, ServerTest, Worker } from '../types.js';
|
9
10
|
import { emitShutdownMessage, sendShutdownMessage } from './messages.js';
|
11
|
+
import assert from 'assert';
|
10
12
|
|
11
13
|
const importMetaUrl = pathToFileURL(__filename).href;
|
12
14
|
|
@@ -14,6 +16,19 @@ export const isShuttingDown = { current: false };
|
|
14
16
|
|
15
17
|
export const configExt = ['.js', '.mjs', '.ts', '.cjs', '.mts', '.cts'];
|
16
18
|
|
19
|
+
const browserTypes = {
|
20
|
+
chromium: 'chromium',
|
21
|
+
'chromium-headless-shell': 'chromium',
|
22
|
+
chrome: 'chromium',
|
23
|
+
'chrome-beta': 'chromium',
|
24
|
+
msedge: 'chromium',
|
25
|
+
'msedge-beta': 'chromium',
|
26
|
+
'msedge-dev': 'chromium',
|
27
|
+
'bidi-chromium': 'chromium',
|
28
|
+
firefox: 'firefox',
|
29
|
+
webkit: 'webkit',
|
30
|
+
} as const;
|
31
|
+
|
17
32
|
export const skipOptionKeys = ['in', 'kinds', 'stories', 'tests', 'reason'];
|
18
33
|
|
19
34
|
function matchBy(pattern: string | string[] | RegExp | undefined, value: string): boolean {
|
@@ -106,6 +121,23 @@ export function gracefullyKill(worker: Worker): void {
|
|
106
121
|
sendShutdownMessage(worker);
|
107
122
|
}
|
108
123
|
|
124
|
+
export function shutdown(): void {
|
125
|
+
process.exit();
|
126
|
+
}
|
127
|
+
|
128
|
+
export function shutdownWithError(): void {
|
129
|
+
process.exit(1);
|
130
|
+
}
|
131
|
+
|
132
|
+
export function resolvePlaywrightBrowserType(browserName: string): (typeof browserTypes)[keyof typeof browserTypes] {
|
133
|
+
assert(
|
134
|
+
browserName in browserTypes,
|
135
|
+
new Error(`Failed to match browser name "${browserName}" to playwright browserType`),
|
136
|
+
);
|
137
|
+
|
138
|
+
return browserTypes[browserName as keyof typeof browserTypes];
|
139
|
+
}
|
140
|
+
|
109
141
|
export async function getCreeveyCache(): Promise<string | undefined> {
|
110
142
|
const { default: findCacheDir } = await import('find-cache-dir');
|
111
143
|
return findCacheDir({ name: 'creevey', cwd: dirname(fileURLToPath(importMetaUrl)) });
|
@@ -141,11 +173,12 @@ export function testsToImages(tests: (TestData | undefined)[]): Set<string> {
|
|
141
173
|
|
142
174
|
// https://tuhrig.de/how-to-know-you-are-inside-a-docker-container/
|
143
175
|
export const isInsideDocker =
|
144
|
-
fs.existsSync('/proc/1/cgroup') && fs.readFileSync('/proc/1/cgroup', 'utf-8').includes('docker')
|
176
|
+
(fs.existsSync('/proc/1/cgroup') && fs.readFileSync('/proc/1/cgroup', 'utf-8').includes('docker')) ||
|
177
|
+
process.env.DOCKER === 'true';
|
145
178
|
|
146
179
|
export const downloadBinary = (downloadUrl: string, destination: string): Promise<void> =>
|
147
180
|
new Promise((resolve, reject) =>
|
148
|
-
get(downloadUrl, (response) => {
|
181
|
+
https.get(downloadUrl, (response) => {
|
149
182
|
if (response.statusCode == 302) {
|
150
183
|
const { location } = response.headers;
|
151
184
|
if (!location) {
|
@@ -214,3 +247,26 @@ export async function loadThroughTSX<T>(
|
|
214
247
|
|
215
248
|
return result;
|
216
249
|
}
|
250
|
+
|
251
|
+
export function waitOnUrl(url: string, timeout: number, delay: number) {
|
252
|
+
const startTime = Date.now();
|
253
|
+
return new Promise<void>((resolve, reject) => {
|
254
|
+
const interval = setInterval(() => {
|
255
|
+
http
|
256
|
+
.get(url, (response) => {
|
257
|
+
if (response.statusCode === 200) {
|
258
|
+
clearInterval(interval);
|
259
|
+
resolve();
|
260
|
+
}
|
261
|
+
})
|
262
|
+
.on('error', () => {
|
263
|
+
// Ignore HTTP errors
|
264
|
+
});
|
265
|
+
|
266
|
+
if (Date.now() - startTime > timeout) {
|
267
|
+
clearInterval(interval);
|
268
|
+
reject(new Error(`${url} didn't respond within ${timeout / 1000} seconds`));
|
269
|
+
}
|
270
|
+
}, delay);
|
271
|
+
});
|
272
|
+
}
|
package/src/types.ts
CHANGED
@@ -4,7 +4,7 @@ import type Pixelmatch from 'pixelmatch';
|
|
4
4
|
import type { ODiffOptions } from 'odiff-bin';
|
5
5
|
import type { expect } from 'chai';
|
6
6
|
import type EventEmitter from 'events';
|
7
|
-
import { LaunchOptions } from 'playwright-core';
|
7
|
+
import type { LaunchOptions } from 'playwright-core';
|
8
8
|
// import type { Browser } from 'playwright-core';
|
9
9
|
|
10
10
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
@@ -145,7 +145,14 @@ export interface BrowserConfigObject {
|
|
145
145
|
[name: string]: unknown;
|
146
146
|
};
|
147
147
|
|
148
|
-
playwrightOptions?: Omit<LaunchOptions, 'logger'
|
148
|
+
playwrightOptions?: Omit<LaunchOptions, 'logger'> & {
|
149
|
+
trace?: {
|
150
|
+
screenshots?: boolean;
|
151
|
+
snapshots?: boolean;
|
152
|
+
sources?: boolean;
|
153
|
+
path: string;
|
154
|
+
};
|
155
|
+
};
|
149
156
|
}
|
150
157
|
|
151
158
|
export type StorybookGlobals = Record<string, unknown>;
|
@@ -200,6 +207,11 @@ export interface Config {
|
|
200
207
|
* Url where storybook hosted on
|
201
208
|
*/
|
202
209
|
resolveStorybookUrl?: () => Promise<string>;
|
210
|
+
/**
|
211
|
+
* Command to automatically start Storybook if it is not running.
|
212
|
+
* For example, `npm run storybook`, `yarn run storybook` etc.
|
213
|
+
*/
|
214
|
+
storybookAutorunCmd?: string;
|
203
215
|
/**
|
204
216
|
* Absolute path to directory with reference images
|
205
217
|
* @default path.join(process.cwd(), './images')
|
@@ -354,6 +366,8 @@ export interface Options {
|
|
354
366
|
reportDir?: string;
|
355
367
|
gridUrl?: string;
|
356
368
|
storybookUrl?: string;
|
369
|
+
storybookAutorunCmd?: string;
|
370
|
+
saveReport: boolean;
|
357
371
|
failFast?: boolean;
|
358
372
|
odiff?: boolean;
|
359
373
|
}
|