@argos-ci/cypress 6.0.7 → 6.1.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/dist/support.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  } from "@argos-ci/util/browser";
12
12
 
13
13
  // package.json
14
- var version = "6.0.6";
14
+ var version = "6.0.7";
15
15
 
16
16
  // src/shared.ts
17
17
  var NAME_PREFIX = "argos/";
package/dist/task.cjs CHANGED
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/task.ts
31
31
  var task_exports = {};
32
32
  __export(task_exports, {
33
+ argosAfterRun: () => argosAfterRun,
34
+ argosAfterScreenshot: () => argosAfterScreenshot,
33
35
  registerArgosTask: () => registerArgosTask
34
36
  });
35
37
  module.exports = __toCommonJS(task_exports);
@@ -56,65 +58,78 @@ async function createDirectory(directory) {
56
58
  const { createDirectory: createDirectory2 } = await import("@argos-ci/util");
57
59
  await createDirectory2(directory);
58
60
  }
59
- function registerArgosTask(on, config, options) {
60
- on("after:screenshot", async (details) => {
61
- const { uploadToArgos = true } = options || {};
62
- if (!uploadToArgos) {
63
- return { path: details.path };
64
- }
65
- const argosScreenshotsDir = await getScreenshotsDirectory();
66
- if (details.name?.startsWith(NAME_PREFIX)) {
67
- const newPath2 = (0, import_node_path.join)(
68
- argosScreenshotsDir,
69
- details.name.slice(NAME_PREFIX.length) + (0, import_node_path.extname)(details.path)
70
- );
71
- await createDirectory((0, import_node_path.dirname)(newPath2));
72
- await (0, import_promises.copyFile)(details.path, newPath2);
73
- return { path: newPath2 };
74
- }
75
- const { screenshotsFolder } = config;
76
- if (!screenshotsFolder) {
77
- throw new Error(
78
- "Cypress screenshotsFolder is not defined. Please set it in your cypress.config.js"
79
- );
80
- }
81
- if (!details.path.startsWith(screenshotsFolder)) {
82
- throw new Error(
83
- `Cypress screenshot path ${details.path} does not start with the configured screenshotsFolder ${screenshotsFolder}. Please check your cypress.config.js.`
84
- );
85
- }
86
- const relativePath = details.path.slice(
87
- screenshotsFolder.length + (screenshotsFolder.endsWith("/") ? 0 : 1)
61
+ function getArgosConfigFromOptions(options) {
62
+ return {
63
+ uploadToArgos: options?.uploadToArgos ?? true
64
+ };
65
+ }
66
+ async function argosAfterScreenshot(config, details, options) {
67
+ const { uploadToArgos } = getArgosConfigFromOptions(options);
68
+ if (!uploadToArgos) {
69
+ return { path: details.path };
70
+ }
71
+ const argosScreenshotsDir = await getScreenshotsDirectory();
72
+ if (details.name?.startsWith(NAME_PREFIX)) {
73
+ const newPath2 = (0, import_node_path.join)(
74
+ argosScreenshotsDir,
75
+ details.name.slice(NAME_PREFIX.length) + (0, import_node_path.extname)(details.path)
88
76
  );
89
- const newPath = (0, import_node_path.join)(argosScreenshotsDir, relativePath);
90
- await createDirectory((0, import_node_path.dirname)(newPath));
91
- await (0, import_promises.copyFile)(details.path, newPath);
92
- return { path: (0, import_node_path.join)(argosScreenshotsDir, relativePath) };
93
- });
94
- on("after:run", async (results) => {
95
- const { uploadToArgos = true } = options || {};
96
- if (!uploadToArgos) {
97
- return;
98
- }
99
- const argosScreenshotsDir = await getScreenshotsDirectory();
100
- const res = await (0, import_core.upload)({
101
- ...options,
102
- files: ["**/*.png"],
103
- root: argosScreenshotsDir,
104
- metadata: {
105
- testReport: checkIsCypressFailedResult(results) ? { status: "failed" } : {
106
- status: "passed",
107
- stats: {
108
- startTime: results.startedTestsAt,
109
- duration: results.totalDuration
110
- }
77
+ await createDirectory((0, import_node_path.dirname)(newPath2));
78
+ await (0, import_promises.copyFile)(details.path, newPath2);
79
+ return { path: newPath2 };
80
+ }
81
+ const { screenshotsFolder } = config;
82
+ if (!screenshotsFolder) {
83
+ throw new Error(
84
+ "Cypress screenshotsFolder is not defined. Please set it in your cypress.config.js"
85
+ );
86
+ }
87
+ if (!details.path.startsWith(screenshotsFolder)) {
88
+ throw new Error(
89
+ `Cypress screenshot path ${details.path} does not start with the configured screenshotsFolder ${screenshotsFolder}. Please check your cypress.config.js.`
90
+ );
91
+ }
92
+ const relativePath = details.path.slice(
93
+ screenshotsFolder.length + (screenshotsFolder.endsWith("/") ? 0 : 1)
94
+ );
95
+ const newPath = (0, import_node_path.join)(argosScreenshotsDir, relativePath);
96
+ await createDirectory((0, import_node_path.dirname)(newPath));
97
+ await (0, import_promises.copyFile)(details.path, newPath);
98
+ return { path: (0, import_node_path.join)(argosScreenshotsDir, relativePath) };
99
+ }
100
+ async function argosAfterRun(_config, results, options) {
101
+ const { uploadToArgos } = getArgosConfigFromOptions(options);
102
+ if (!uploadToArgos) {
103
+ return;
104
+ }
105
+ const argosScreenshotsDir = await getScreenshotsDirectory();
106
+ const res = await (0, import_core.upload)({
107
+ ...options,
108
+ files: ["**/*.png"],
109
+ root: argosScreenshotsDir,
110
+ metadata: {
111
+ testReport: checkIsCypressFailedResult(results) ? { status: "failed" } : {
112
+ status: "passed",
113
+ stats: {
114
+ startTime: results.startedTestsAt,
115
+ duration: results.totalDuration
111
116
  }
112
117
  }
113
- });
114
- console.log(`\u2705 Argos build created: ${res.build.url}`);
118
+ }
119
+ });
120
+ console.log(`\u2705 Argos build created: ${res.build.url}`);
121
+ }
122
+ function registerArgosTask(on, config, options) {
123
+ on("after:screenshot", (details) => {
124
+ return argosAfterScreenshot(config, details, options);
125
+ });
126
+ on("after:run", async (results) => {
127
+ return argosAfterRun(config, results, options);
115
128
  });
116
129
  }
117
130
  // Annotate the CommonJS export names for ESM import in node:
118
131
  0 && (module.exports = {
132
+ argosAfterRun,
133
+ argosAfterScreenshot,
119
134
  registerArgosTask
120
135
  });
package/dist/task.d.cts CHANGED
@@ -7,6 +7,21 @@ type RegisterArgosTaskOptions = Omit<UploadParameters, "files" | "root" | "metad
7
7
  */
8
8
  uploadToArgos?: boolean;
9
9
  };
10
+ /**
11
+ * Cypress "after:screenshot" event handler.
12
+ * - Move screenshots to Argos directory
13
+ */
14
+ declare function argosAfterScreenshot(config: Cypress.PluginConfigOptions, details: Cypress.ScreenshotDetails, options?: RegisterArgosTaskOptions): Promise<{
15
+ path: string;
16
+ }>;
17
+ /**
18
+ * Cypress "after:run" event handler.
19
+ * - Upload screenshots to Argos
20
+ */
21
+ declare function argosAfterRun(_config: Cypress.PluginConfigOptions, results: CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult, options?: RegisterArgosTaskOptions): Promise<void>;
22
+ /**
23
+ * Register the Argos tasks for Cypress.
24
+ */
10
25
  declare function registerArgosTask(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, options?: RegisterArgosTaskOptions): void;
11
26
 
12
- export { type RegisterArgosTaskOptions, registerArgosTask };
27
+ export { type RegisterArgosTaskOptions, argosAfterRun, argosAfterScreenshot, registerArgosTask };
package/dist/task.d.ts CHANGED
@@ -7,6 +7,21 @@ type RegisterArgosTaskOptions = Omit<UploadParameters, "files" | "root" | "metad
7
7
  */
8
8
  uploadToArgos?: boolean;
9
9
  };
10
+ /**
11
+ * Cypress "after:screenshot" event handler.
12
+ * - Move screenshots to Argos directory
13
+ */
14
+ declare function argosAfterScreenshot(config: Cypress.PluginConfigOptions, details: Cypress.ScreenshotDetails, options?: RegisterArgosTaskOptions): Promise<{
15
+ path: string;
16
+ }>;
17
+ /**
18
+ * Cypress "after:run" event handler.
19
+ * - Upload screenshots to Argos
20
+ */
21
+ declare function argosAfterRun(_config: Cypress.PluginConfigOptions, results: CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult, options?: RegisterArgosTaskOptions): Promise<void>;
22
+ /**
23
+ * Register the Argos tasks for Cypress.
24
+ */
10
25
  declare function registerArgosTask(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions, options?: RegisterArgosTaskOptions): void;
11
26
 
12
- export { type RegisterArgosTaskOptions, registerArgosTask };
27
+ export { type RegisterArgosTaskOptions, argosAfterRun, argosAfterScreenshot, registerArgosTask };
package/dist/task.js CHANGED
@@ -22,64 +22,77 @@ async function createDirectory(directory) {
22
22
  const { createDirectory: createDirectory2 } = await import("@argos-ci/util");
23
23
  await createDirectory2(directory);
24
24
  }
25
- function registerArgosTask(on, config, options) {
26
- on("after:screenshot", async (details) => {
27
- const { uploadToArgos = true } = options || {};
28
- if (!uploadToArgos) {
29
- return { path: details.path };
30
- }
31
- const argosScreenshotsDir = await getScreenshotsDirectory();
32
- if (details.name?.startsWith(NAME_PREFIX)) {
33
- const newPath2 = join(
34
- argosScreenshotsDir,
35
- details.name.slice(NAME_PREFIX.length) + extname(details.path)
36
- );
37
- await createDirectory(dirname(newPath2));
38
- await copyFile(details.path, newPath2);
39
- return { path: newPath2 };
40
- }
41
- const { screenshotsFolder } = config;
42
- if (!screenshotsFolder) {
43
- throw new Error(
44
- "Cypress screenshotsFolder is not defined. Please set it in your cypress.config.js"
45
- );
46
- }
47
- if (!details.path.startsWith(screenshotsFolder)) {
48
- throw new Error(
49
- `Cypress screenshot path ${details.path} does not start with the configured screenshotsFolder ${screenshotsFolder}. Please check your cypress.config.js.`
50
- );
51
- }
52
- const relativePath = details.path.slice(
53
- screenshotsFolder.length + (screenshotsFolder.endsWith("/") ? 0 : 1)
25
+ function getArgosConfigFromOptions(options) {
26
+ return {
27
+ uploadToArgos: options?.uploadToArgos ?? true
28
+ };
29
+ }
30
+ async function argosAfterScreenshot(config, details, options) {
31
+ const { uploadToArgos } = getArgosConfigFromOptions(options);
32
+ if (!uploadToArgos) {
33
+ return { path: details.path };
34
+ }
35
+ const argosScreenshotsDir = await getScreenshotsDirectory();
36
+ if (details.name?.startsWith(NAME_PREFIX)) {
37
+ const newPath2 = join(
38
+ argosScreenshotsDir,
39
+ details.name.slice(NAME_PREFIX.length) + extname(details.path)
54
40
  );
55
- const newPath = join(argosScreenshotsDir, relativePath);
56
- await createDirectory(dirname(newPath));
57
- await copyFile(details.path, newPath);
58
- return { path: join(argosScreenshotsDir, relativePath) };
59
- });
60
- on("after:run", async (results) => {
61
- const { uploadToArgos = true } = options || {};
62
- if (!uploadToArgos) {
63
- return;
64
- }
65
- const argosScreenshotsDir = await getScreenshotsDirectory();
66
- const res = await upload({
67
- ...options,
68
- files: ["**/*.png"],
69
- root: argosScreenshotsDir,
70
- metadata: {
71
- testReport: checkIsCypressFailedResult(results) ? { status: "failed" } : {
72
- status: "passed",
73
- stats: {
74
- startTime: results.startedTestsAt,
75
- duration: results.totalDuration
76
- }
41
+ await createDirectory(dirname(newPath2));
42
+ await copyFile(details.path, newPath2);
43
+ return { path: newPath2 };
44
+ }
45
+ const { screenshotsFolder } = config;
46
+ if (!screenshotsFolder) {
47
+ throw new Error(
48
+ "Cypress screenshotsFolder is not defined. Please set it in your cypress.config.js"
49
+ );
50
+ }
51
+ if (!details.path.startsWith(screenshotsFolder)) {
52
+ throw new Error(
53
+ `Cypress screenshot path ${details.path} does not start with the configured screenshotsFolder ${screenshotsFolder}. Please check your cypress.config.js.`
54
+ );
55
+ }
56
+ const relativePath = details.path.slice(
57
+ screenshotsFolder.length + (screenshotsFolder.endsWith("/") ? 0 : 1)
58
+ );
59
+ const newPath = join(argosScreenshotsDir, relativePath);
60
+ await createDirectory(dirname(newPath));
61
+ await copyFile(details.path, newPath);
62
+ return { path: join(argosScreenshotsDir, relativePath) };
63
+ }
64
+ async function argosAfterRun(_config, results, options) {
65
+ const { uploadToArgos } = getArgosConfigFromOptions(options);
66
+ if (!uploadToArgos) {
67
+ return;
68
+ }
69
+ const argosScreenshotsDir = await getScreenshotsDirectory();
70
+ const res = await upload({
71
+ ...options,
72
+ files: ["**/*.png"],
73
+ root: argosScreenshotsDir,
74
+ metadata: {
75
+ testReport: checkIsCypressFailedResult(results) ? { status: "failed" } : {
76
+ status: "passed",
77
+ stats: {
78
+ startTime: results.startedTestsAt,
79
+ duration: results.totalDuration
77
80
  }
78
81
  }
79
- });
80
- console.log(`\u2705 Argos build created: ${res.build.url}`);
82
+ }
83
+ });
84
+ console.log(`\u2705 Argos build created: ${res.build.url}`);
85
+ }
86
+ function registerArgosTask(on, config, options) {
87
+ on("after:screenshot", (details) => {
88
+ return argosAfterScreenshot(config, details, options);
89
+ });
90
+ on("after:run", async (results) => {
91
+ return argosAfterRun(config, results, options);
81
92
  });
82
93
  }
83
94
  export {
95
+ argosAfterRun,
96
+ argosAfterScreenshot,
84
97
  registerArgosTask
85
98
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/cypress",
3
3
  "description": "Cypress SDK for visual testing with Argos.",
4
- "version": "6.0.7",
4
+ "version": "6.1.0",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@argos-ci/browser": "5.0.0",
49
- "@argos-ci/core": "4.1.3",
49
+ "@argos-ci/core": "4.1.4",
50
50
  "@argos-ci/util": "3.1.0",
51
51
  "cypress-wait-until": "^3.0.2"
52
52
  },
@@ -67,5 +67,5 @@
67
67
  "check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
68
68
  "lint": "eslint ."
69
69
  },
70
- "gitHead": "9bda48090685f3215301526c7d979716d485f3ed"
70
+ "gitHead": "a1f55cdee00ce144eb5b0f7ef08e451867d0c129"
71
71
  }