@cappa/core 0.4.1 → 0.4.3

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/src/types.ts DELETED
@@ -1,164 +0,0 @@
1
- import type { Locator } from "playwright-core";
2
- import type { Plugin, PluginDef } from "./plugin";
3
-
4
- export type PossiblePromise<T> = Promise<T> | T;
5
-
6
- export interface ConfigEnv {
7
- /**
8
- * The CLI command being executed, for example `capture` or `review`.
9
- */
10
- command?: string;
11
- /**
12
- * The mode the CLI is running in, defaults to `process.env.NODE_ENV`.
13
- */
14
- mode: string;
15
- /**
16
- * The environment variables available when the configuration is loaded.
17
- */
18
- env: NodeJS.ProcessEnv;
19
- }
20
-
21
- /**
22
- * Configuration for the comparison of images
23
- */
24
- export interface DiffConfig {
25
- /**
26
- * Matching threshold (0-1). Lower = more sensitive
27
- * Default = 0.1
28
- *
29
- * This affects how similar a pixel needs to be in the reference image to be considered the same.
30
- */
31
- threshold?: number;
32
- /**
33
- * Include anti-aliased pixels in diff count
34
- * Default = false
35
- *
36
- * For most users this should be false, because it makes comparisons very sensitive to sub-pixel differences of
37
- * fonts and other UI elements.
38
- */
39
- includeAA?: boolean;
40
- /**
41
- * Use fast buffer comparison for identical images
42
- * Default = true
43
- */
44
- fastBufferCheck?: boolean;
45
- /**
46
- * Maximum number of different pixels
47
- * Default = 0
48
- *
49
- * The amount of pixels that can be different before the comparison fails.
50
- */
51
- maxDiffPixels?: number;
52
- /**
53
- * Maximum percentage of pixels different
54
- * Default = 0
55
- *
56
- * The amount of pixels that can be different before the comparison fails as a percentage of the total pixels.
57
- * 0 = no difference, 100 = 100% difference.
58
- *
59
- * Since this is a relative value, it is affected by the size of the images. A 100px image with a 10% difference
60
- * is 10 pixels different, but a 1000px image with a 10% difference is 100 pixels different. On very large full page screenshots
61
- * this can mean that small changes still slip through.
62
- */
63
- maxDiffPercentage?: number;
64
- }
65
-
66
- /**
67
- * Config used in `cappa.config.ts`
68
- *
69
- * @example
70
- * import { defineConfig } from '@cappa/core'
71
- * export default defineConfig({
72
- * ...
73
- * })
74
- */
75
- export type UserConfig = {
76
- /**
77
- * The directory to save screenshots and other files in
78
- */
79
- outputDir?: string;
80
- /**
81
- * Configuration for the comparison of images
82
- */
83
- diff?: DiffConfig;
84
- /**
85
- * The number of times to retry a screenshot if it fails
86
- */
87
- retries?: number;
88
- /**
89
- * The number of parallel browser contexts to use for taking screenshots
90
- */
91
- concurrency?: number;
92
- /**
93
- * Whether to log Playwright console events while executing capture tasks.
94
- *
95
- * Enabled by default to aid in debugging. Disable to reduce noise in the
96
- * console output when you do not need the additional details.
97
- */
98
- logConsoleEvents?: boolean;
99
- /**
100
- * An array of Cappa plugins used for generation.
101
- * Each plugin may have additional configurable options (defined within the plugin itself).
102
- */
103
- plugins?: Array<Plugin | PluginDef>;
104
- /**
105
- * Callback executed when screenshots fail comparison.
106
- * Receives the failing screenshots so they can be uploaded or processed.
107
- */
108
- onFail?: (screenshots: FailedScreenshot[]) => PossiblePromise<void>;
109
- };
110
-
111
- export type Viewport = { width: number; height: number };
112
-
113
- export type ScreenshotSettings = {
114
- fullPage?: boolean;
115
- delay?: number;
116
- skip?: boolean;
117
- mask?: Locator[];
118
- omitBackground?: boolean;
119
- viewport?: Viewport;
120
- };
121
-
122
- export type ScreenshotVariant = {
123
- id: string;
124
- label?: string;
125
- filename?: string;
126
- options?: ScreenshotSettings;
127
- };
128
-
129
- export type ScreenshotVariantWithUrl = {
130
- id: string;
131
- label?: string;
132
- filename?: string;
133
- url: string;
134
- options?: ScreenshotSettings;
135
- };
136
-
137
- export type ScreenshotOptions = ScreenshotSettings & {
138
- variants?: ScreenshotVariant[];
139
- };
140
-
141
- export interface Screenshot {
142
- id: string;
143
- name: string;
144
- category: "new" | "deleted" | "changed" | "passed";
145
- actualPath?: string;
146
- expectedPath?: string;
147
- diffPath?: string;
148
- approved?: boolean;
149
- }
150
-
151
- export type FailedScreenshot = Screenshot & {
152
- /**
153
- * Absolute path to the actual screenshot on disk.
154
- */
155
- absoluteActualPath?: string;
156
- /**
157
- * Absolute path to the expected screenshot on disk.
158
- */
159
- absoluteExpectedPath?: string;
160
- /**
161
- * Absolute path to the diff screenshot on disk.
162
- */
163
- absoluteDiffPath?: string;
164
- };
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "include": [
4
- "src/**/*",
5
- "./package.json",
6
- "./tsdown.config.ts",
7
- "./vitest.config.ts"
8
- ]
9
- }
package/tsdown.config.ts DELETED
@@ -1,11 +0,0 @@
1
- import { defineConfig } from "tsdown";
2
-
3
- export default defineConfig({
4
- entry: ["src/index.ts"],
5
- dts: true,
6
- format: ["esm", "cjs"],
7
- platform: "node",
8
- sourcemap: true,
9
- shims: true,
10
- exports: true,
11
- });
package/vitest.config.ts DELETED
@@ -1,11 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- test: {
5
- environment: "node",
6
- coverage: {
7
- reporter: ["text", "json", "html"],
8
- exclude: ["node_modules/", "dist/", "**/*.test.ts", "**/*.config.ts"],
9
- },
10
- },
11
- });