@trackunit/iris-app-e2e 1.8.90 → 1.8.91
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 +2511 -0
- package/generators.json +12 -0
- package/package.json +19 -14
- package/src/commands/defaultCommands.js +135 -0
- package/src/commands/defaultCommands.js.map +1 -0
- package/src/generators/e2e-configuration/README.md +79 -0
- package/src/generators/e2e-configuration/files/root/cypress/e2e/app.cy.ts__tmpl__ +18 -0
- package/src/generators/e2e-configuration/files/root/cypress/fixtures/auth.json__tmpl__ +4 -0
- package/src/generators/e2e-configuration/files/root/cypress/support/commands.ts__tmpl__ +3 -0
- package/src/generators/e2e-configuration/files/root/cypress/support/e2e.ts__tmpl__ +18 -0
- package/src/generators/e2e-configuration/files/root/cypress/tsconfig.json__tmpl__ +17 -0
- package/src/generators/e2e-configuration/files/root/cypress.config.ts__tmpl__ +25 -0
- package/src/generators/e2e-configuration/generator.js +238 -0
- package/src/generators/e2e-configuration/generator.js.map +1 -0
- package/src/generators/e2e-configuration/schema.json +20 -0
- package/src/index.js +16 -0
- package/src/index.js.map +1 -0
- package/src/plugins/createLogFile.js +42 -0
- package/src/plugins/createLogFile.js.map +1 -0
- package/src/plugins/defaultPlugins.js +142 -0
- package/src/plugins/defaultPlugins.js.map +1 -0
- package/src/plugins/nxPreset.js +41 -0
- package/src/plugins/nxPreset.js.map +1 -0
- package/src/plugins/writeFileWithPrettier.js +35 -0
- package/src/plugins/writeFileWithPrettier.js.map +1 -0
- package/src/setup/defaultE2ESetup.js +45 -0
- package/src/setup/defaultE2ESetup.js.map +1 -0
- package/src/setup/setupHarRecording.js +24 -0
- package/src/setup/setupHarRecording.js.map +1 -0
- package/src/support.js +13 -0
- package/src/support.js.map +1 -0
- package/src/utils/Codeowner.js +136 -0
- package/src/utils/Codeowner.js.map +1 -0
- package/src/utils/fileNameBuilder.js +38 -0
- package/src/utils/fileNameBuilder.js.map +1 -0
- package/src/utils/fileUpdater.js +37 -0
- package/src/utils/fileUpdater.js.map +1 -0
- package/index.cjs.default.js +0 -1
- package/index.cjs.js +0 -422
- package/index.cjs.mjs +0 -2
- package/index.d.ts +0 -1
- package/index.esm.js +0 -398
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/index";
|
package/index.esm.js
DELETED
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
import fs, { writeFileSync, existsSync, readFileSync } from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import path__default from 'path';
|
|
4
|
-
import crypto from 'crypto';
|
|
5
|
-
import { parse } from 'node-xlsx';
|
|
6
|
-
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
|
|
7
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
8
|
-
|
|
9
|
-
/* eslint-disable no-console */
|
|
10
|
-
/**
|
|
11
|
-
* Writes a file with Prettier formatting applied.
|
|
12
|
-
* Automatically detects parser based on file extension.
|
|
13
|
-
*/
|
|
14
|
-
const writeFileWithPrettier = async (nxRoot, filePath, content, writeOptions = { encoding: "utf-8" }, writer) => {
|
|
15
|
-
const prettierConfigPath = path.join(nxRoot, ".prettierrc");
|
|
16
|
-
const options = await writer
|
|
17
|
-
.resolveConfig(prettierConfigPath)
|
|
18
|
-
.catch(error => console.log("Prettier config error: ", error));
|
|
19
|
-
if (!options) {
|
|
20
|
-
throw new Error("Could not find prettier config");
|
|
21
|
-
}
|
|
22
|
-
if (filePath.endsWith("json")) {
|
|
23
|
-
options.parser = "json";
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
options.parser = "typescript";
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
const prettySrc = await writer.format(content, options);
|
|
30
|
-
writeFileSync(filePath, prettySrc, writeOptions);
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
console.error("Error in prettier.format:", error);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const isNetworkCall = (log) => {
|
|
38
|
-
return log.type === "cy:fetch" || log.type === "cy:request" || log.type === "cy:response" || log.type === "cy:xrh";
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Creates log files for Cypress test runs.
|
|
42
|
-
* Generates separate files for all logs, errors, and network errors.
|
|
43
|
-
*/
|
|
44
|
-
function createLogFile(nxRoot, logsPath, fileNameWithoutExtension, logs, logWriter) {
|
|
45
|
-
if (!existsSync(logsPath)) {
|
|
46
|
-
fs.mkdirSync(logsPath, { recursive: true });
|
|
47
|
-
}
|
|
48
|
-
const logFilePath = path__default.join(logsPath, fileNameWithoutExtension);
|
|
49
|
-
writeFileWithPrettier(nxRoot, logFilePath + "-all.json", JSON.stringify(logs), { flag: "a" }, logWriter);
|
|
50
|
-
const errorCmds = logs.filter(log => log.severity === "error" &&
|
|
51
|
-
// This seems to be when apollo has cancelled requests it marks it as failed to fetch only on cypress ?!??
|
|
52
|
-
// might be fixed by https://github.com/Trackunit/manager/pull/12917
|
|
53
|
-
!log.message.includes("TypeError: Failed to fetch"));
|
|
54
|
-
if (errorCmds.length > 0) {
|
|
55
|
-
writeFileWithPrettier(nxRoot, logFilePath + "-errors.json", JSON.stringify(errorCmds), {
|
|
56
|
-
flag: "a",
|
|
57
|
-
}, logWriter);
|
|
58
|
-
}
|
|
59
|
-
const networkErrorsCmds = logs.filter(log => isNetworkCall(log) &&
|
|
60
|
-
!log.message.includes("Status: 200") &&
|
|
61
|
-
log.severity !== "success" &&
|
|
62
|
-
!log.message.includes("sentry.io/api/") &&
|
|
63
|
-
// This seems to be when apollo has cancelled requests it marks it as failed to fetch only on cypress ?!??
|
|
64
|
-
!log.message.includes("TypeError: Failed to fetch"));
|
|
65
|
-
if (networkErrorsCmds.length > 0) {
|
|
66
|
-
writeFileWithPrettier(nxRoot, logFilePath + "-network-errors.json", JSON.stringify(networkErrorsCmds), {
|
|
67
|
-
flag: "a",
|
|
68
|
-
}, logWriter);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Parses lines from a CODEOWNERS‐style file into a mapping of patterns → owners.
|
|
74
|
-
* Skips blank lines and comments (lines beginning with `#`).
|
|
75
|
-
*
|
|
76
|
-
* @param {string[]} lines - Each element is a line from your CODEOWNERS file.
|
|
77
|
-
* @returns {Record<string, string>} An object whose keys are normalized path patterns (no leading/trailing slashes)
|
|
78
|
-
* and whose values are the owner (e.g. a GitHub team handle).
|
|
79
|
-
* @example
|
|
80
|
-
* ```ts
|
|
81
|
-
* const lines = [
|
|
82
|
-
* "# Our CODEOWNERS",
|
|
83
|
-
* "/src @team/backend",
|
|
84
|
-
* "README.md @team/docs",
|
|
85
|
-
* "", // blank lines ignored
|
|
86
|
-
* "# end of file"
|
|
87
|
-
* ];
|
|
88
|
-
* const owners = parseCodeowners(lines);
|
|
89
|
-
* // → { "src": "@team/backend", "README.md": "@team/docs" }
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
const parseCodeowners = (lines) => {
|
|
93
|
-
const patterns = {};
|
|
94
|
-
for (const line of lines) {
|
|
95
|
-
const trimmed = line.trim();
|
|
96
|
-
if (!trimmed || trimmed.startsWith("#")) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const [pattern, owner] = trimmed.split(/\s+/, 2);
|
|
100
|
-
if (pattern && owner) {
|
|
101
|
-
const normalizedPattern = pattern.replace(/^\/+|\/+$/g, "");
|
|
102
|
-
patterns[normalizedPattern] = owner;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return patterns;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Converts a full team handle (potentially namespaced and with platform suffix)
|
|
109
|
-
* into its “short” team name.
|
|
110
|
-
*
|
|
111
|
-
* - Strips any leading `@org/` prefix
|
|
112
|
-
* - Removes `-be` or `-fe` suffix if present
|
|
113
|
-
*
|
|
114
|
-
* @param {string} teamName - e.g. `"@trackunit/backend-be"` or `"@trackunit/frontend-fe"`
|
|
115
|
-
* @returns {string} e.g. `"backend"` or `"frontend"`
|
|
116
|
-
* @example
|
|
117
|
-
* ```ts
|
|
118
|
-
* toShortTeamName("@trackunit/backend-be"); // → "backend"
|
|
119
|
-
* toShortTeamName("@trackunit/frontend-fe"); // → "frontend"
|
|
120
|
-
* toShortTeamName("infra"); // → "infra"
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
const toShortTeamName = (teamName) => {
|
|
124
|
-
if (!teamName) {
|
|
125
|
-
return undefined;
|
|
126
|
-
}
|
|
127
|
-
let shortName = teamName;
|
|
128
|
-
if (teamName.startsWith("@")) {
|
|
129
|
-
shortName = shortName.slice(shortName.indexOf("/") + 1);
|
|
130
|
-
}
|
|
131
|
-
if (shortName.endsWith("-be") || shortName.endsWith("-fe")) {
|
|
132
|
-
shortName = shortName.slice(0, shortName.lastIndexOf("-"));
|
|
133
|
-
}
|
|
134
|
-
return shortName;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Recursively looks up the CODEOWNER for a given file or directory path
|
|
138
|
-
* by reading your workspace’s CODEOWNERS file.
|
|
139
|
-
*
|
|
140
|
-
* Walks up the directory tree until it finds a matching pattern. If no
|
|
141
|
-
* deeper match is found but there is a `"."` entry, returns that.
|
|
142
|
-
*
|
|
143
|
-
* @param {string} currentPath - Absolute path to the file/directory you’re querying.
|
|
144
|
-
* @param {string} workspaceRoot - Absolute path to your repo/workspace root.
|
|
145
|
-
* @param {string} [codeownersFileName="TEAM_CODEOWNERS"] - Filename to read at the root.
|
|
146
|
-
* @returns {string|undefined} The owner handle (e.g. `"@team/backend"`) or `undefined` if none found.
|
|
147
|
-
* @example
|
|
148
|
-
* ```ts
|
|
149
|
-
* // Suppose your repo root has a TEAM_CODEOWNERS file containing:
|
|
150
|
-
* // src @team/backend
|
|
151
|
-
* // src/utils @team/utils
|
|
152
|
-
* // . @team/root
|
|
153
|
-
*
|
|
154
|
-
* const owner1 = getCodeowner(
|
|
155
|
-
* "/Users/alice/project/src/utils/helpers.ts",
|
|
156
|
-
* "/Users/alice/project"
|
|
157
|
-
* );
|
|
158
|
-
* // → "@team/utils"
|
|
159
|
-
*
|
|
160
|
-
* const owner2 = getCodeowner(
|
|
161
|
-
* "/Users/alice/project/other/file.txt",
|
|
162
|
-
* "/Users/alice/project"
|
|
163
|
-
* );
|
|
164
|
-
* // → "@team/root" (falls back to the "." entry)
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
const getCodeowner = (currentPath, workspaceRoot, codeownersFileName = "TEAM_CODEOWNERS") => {
|
|
168
|
-
if (!workspaceRoot) {
|
|
169
|
-
return undefined;
|
|
170
|
-
}
|
|
171
|
-
const codeownersPath = path__default.join(workspaceRoot, codeownersFileName);
|
|
172
|
-
if (!fs.existsSync(codeownersPath)) {
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
const codeownersLines = fs.readFileSync(codeownersPath, "utf8").split("\n");
|
|
176
|
-
const codeowners = parseCodeowners(codeownersLines);
|
|
177
|
-
let relPath = path__default
|
|
178
|
-
.relative(workspaceRoot, currentPath)
|
|
179
|
-
.replace(/\\/g, "/")
|
|
180
|
-
.replace(/^\/+|\/+$/g, "");
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
182
|
-
while (true) {
|
|
183
|
-
const codeowner = codeowners[relPath];
|
|
184
|
-
if (codeowner) {
|
|
185
|
-
return codeowner;
|
|
186
|
-
}
|
|
187
|
-
const parent = path__default.posix.dirname(relPath);
|
|
188
|
-
if ((parent === relPath || parent === ".") && codeowners["."]) {
|
|
189
|
-
return codeowners["."];
|
|
190
|
-
}
|
|
191
|
-
if (parent === relPath || parent === ".") {
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
relPath = parent;
|
|
195
|
-
}
|
|
196
|
-
return undefined;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Sanitizes a string to be safe for use in filenames.
|
|
201
|
-
* Removes special characters and truncates if too long.
|
|
202
|
-
*
|
|
203
|
-
* @param str - The string to sanitize (e.g., test suite or test name)
|
|
204
|
-
* @returns {string} Sanitized string safe for filesystem use
|
|
205
|
-
*/
|
|
206
|
-
function sanitizeForFilename(str) {
|
|
207
|
-
return str
|
|
208
|
-
.replace(/[^a-zA-Z0-9-_\s\[\]\(\)]/g, "") // Remove special chars - with exceptions
|
|
209
|
-
.replace(/-+/g, "-") // Collapse multiple hyphens into one
|
|
210
|
-
.replace(/\s+/g, " ") // Collapse multiple spaces into one
|
|
211
|
-
.replace(/^-|-$/g, ""); // Trim leading/trailing hyphens
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Builds a standardized filename for test artifacts (e.g., HAR files, screenshots).
|
|
215
|
-
* Combines test name, state, and attempt number into a readable filename.
|
|
216
|
-
*
|
|
217
|
-
* @param testName - The name of the test (will be sanitized)
|
|
218
|
-
* @param state - The test state (e.g., 'passed', 'failed')
|
|
219
|
-
* @param currentRetry - The current retry attempt number (0-based)
|
|
220
|
-
* @returns {string} A sanitized filename in the format: "testName (state) (attempt N)"
|
|
221
|
-
* @example
|
|
222
|
-
* fileNameBuilder("Login Flow", "failed", 0)
|
|
223
|
-
* // Returns: "Login Flow (failed) (attempt 1)"
|
|
224
|
-
* @example
|
|
225
|
-
* fileNameBuilder("Test: with -> special chars", "passed", 2)
|
|
226
|
-
* // Returns: "Test with - special chars (passed) (attempt 3)"
|
|
227
|
-
*/
|
|
228
|
-
function fileNameBuilder(testName, state, currentRetry) {
|
|
229
|
-
const fileName = `${testName} ${""} (${state.toLowerCase()})`;
|
|
230
|
-
return sanitizeForFilename(fileName);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Utility function to find NX workspace root by looking for nx.json or workspace.json.
|
|
235
|
-
* This is more reliable than hardcoded relative paths and works from any directory.
|
|
236
|
-
*
|
|
237
|
-
* @param startDir Starting directory for the search (defaults to current working directory)
|
|
238
|
-
* @returns {string} Absolute path to the workspace root
|
|
239
|
-
* @throws Error if workspace root cannot be found
|
|
240
|
-
*/
|
|
241
|
-
function findWorkspaceRoot(startDir = process.cwd()) {
|
|
242
|
-
let currentDir = startDir;
|
|
243
|
-
while (currentDir !== path__default.dirname(currentDir)) {
|
|
244
|
-
if (existsSync(path__default.join(currentDir, "nx.json")) || existsSync(path__default.join(currentDir, "workspace.json"))) {
|
|
245
|
-
return currentDir;
|
|
246
|
-
}
|
|
247
|
-
currentDir = path__default.dirname(currentDir);
|
|
248
|
-
}
|
|
249
|
-
throw new Error("Could not find NX workspace root (nx.json or workspace.json not found)");
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Creates default Cypress configuration for E2E testing.
|
|
253
|
-
* Supports both legacy string parameter (dirname) and new options object for backward compatibility.
|
|
254
|
-
*/
|
|
255
|
-
const defaultCypressConfig = optionsOrDirname => {
|
|
256
|
-
// Support both old API (string/undefined) and new API (object) for backward compatibility
|
|
257
|
-
const options = typeof optionsOrDirname === "object" ? optionsOrDirname : {};
|
|
258
|
-
const { nxRoot: providedNxRoot, outputDirOverride, projectConfig = {}, behaviorConfig = {}, pluginConfig = {}, } = options;
|
|
259
|
-
// Use NX workspace detection for reliable root finding
|
|
260
|
-
const nxRoot = providedNxRoot ?? findWorkspaceRoot();
|
|
261
|
-
// For output path calculation, determine the relative path from caller to workspace root
|
|
262
|
-
const callerDirname = typeof optionsOrDirname === "string" ? optionsOrDirname : process.cwd();
|
|
263
|
-
const relativePath = path__default.relative(nxRoot, callerDirname);
|
|
264
|
-
const dotsToNxRoot = relativePath
|
|
265
|
-
.split(path__default.sep)
|
|
266
|
-
.map(_ => "..")
|
|
267
|
-
.join("/");
|
|
268
|
-
const envOutputDirOverride = process.env.NX_E2E_OUTPUT_DIR || outputDirOverride;
|
|
269
|
-
// Function to build output paths that respects the override
|
|
270
|
-
const buildOutputPath = (subPath) => {
|
|
271
|
-
if (envOutputDirOverride) {
|
|
272
|
-
return path__default.join(dotsToNxRoot, envOutputDirOverride, subPath);
|
|
273
|
-
}
|
|
274
|
-
return `${dotsToNxRoot}/dist/cypress/${relativePath}/${subPath}`;
|
|
275
|
-
};
|
|
276
|
-
return {
|
|
277
|
-
projectId: projectConfig.projectId ?? process.env.CYPRESS_PROJECT_ID,
|
|
278
|
-
defaultCommandTimeout: behaviorConfig.defaultCommandTimeout ?? 20000,
|
|
279
|
-
execTimeout: behaviorConfig.execTimeout ?? 300000,
|
|
280
|
-
taskTimeout: behaviorConfig.taskTimeout ?? 35000,
|
|
281
|
-
pageLoadTimeout: behaviorConfig.pageLoadTimeout ?? 35000,
|
|
282
|
-
// setting to undefined makes no effect on the baseUrl so child projects can override it
|
|
283
|
-
baseUrl: process.env.NX_FEATURE_BRANCH_BASE_URL ?? undefined,
|
|
284
|
-
// This avoid issues with SRI hashes changing
|
|
285
|
-
modifyObstructiveCode: false,
|
|
286
|
-
requestTimeout: behaviorConfig.requestTimeout ?? 25000,
|
|
287
|
-
responseTimeout: behaviorConfig.responseTimeout ?? 150000,
|
|
288
|
-
retries: behaviorConfig.retries ?? {
|
|
289
|
-
runMode: 3,
|
|
290
|
-
openMode: 0,
|
|
291
|
-
},
|
|
292
|
-
fixturesFolder: projectConfig.fixturesFolder ?? "./src/fixtures",
|
|
293
|
-
downloadsFolder: pluginConfig.outputPath ?? buildOutputPath("downloads"),
|
|
294
|
-
logsFolder: pluginConfig.logsFolder ?? buildOutputPath("logs"),
|
|
295
|
-
chromeWebSecurity: false,
|
|
296
|
-
reporter: "junit",
|
|
297
|
-
reporterOptions: {
|
|
298
|
-
mochaFile: buildOutputPath("results-[hash].xml"),
|
|
299
|
-
},
|
|
300
|
-
specPattern: projectConfig.specPattern ?? "src/e2e/**/*.e2e.{js,jsx,ts,tsx}",
|
|
301
|
-
supportFile: projectConfig.supportFile ?? "src/support/e2e.ts",
|
|
302
|
-
nxRoot,
|
|
303
|
-
fileServerFolder: ".",
|
|
304
|
-
video: true,
|
|
305
|
-
trashAssetsBeforeRuns: false, // Don't delete videos from previous test runs (important for sequential runs)
|
|
306
|
-
videosFolder: pluginConfig.videosFolder ?? buildOutputPath("videos"),
|
|
307
|
-
screenshotsFolder: pluginConfig.screenshotsFolder ?? buildOutputPath("screenshots"),
|
|
308
|
-
env: {
|
|
309
|
-
hars_folders: pluginConfig.harFolder ?? buildOutputPath("hars"),
|
|
310
|
-
CYPRESS_RUN_UNIQUE_ID: crypto.randomUUID(),
|
|
311
|
-
},
|
|
312
|
-
};
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Sets up Cypress plugins for logging, tasks, and HAR generation.
|
|
316
|
-
* Configures terminal reporting, XLSX parsing, and HTTP archive recording.
|
|
317
|
-
*/
|
|
318
|
-
const setupPlugins = (on, config, logWriter, installHarGenerator) => {
|
|
319
|
-
/* ---- BEGIN: Logging setup ---- */
|
|
320
|
-
// Read options https://github.com/archfz/cypress-terminal-report
|
|
321
|
-
const options = {
|
|
322
|
-
printLogsToFile: "always", // Ensures logs are always printed to a file
|
|
323
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
|
-
collectTestLogs: (context, logs) => {
|
|
325
|
-
const testName = fileNameBuilder(context.test, context.state);
|
|
326
|
-
createLogFile(config.nxRoot, config.logsFolder, testName, logs, logWriter);
|
|
327
|
-
},
|
|
328
|
-
};
|
|
329
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
330
|
-
require("cypress-terminal-report/src/installLogsPrinter")(on, options);
|
|
331
|
-
/* ---- END: Logging setup ---- */
|
|
332
|
-
/* ---- BEGIN: Task setup ---- */
|
|
333
|
-
on("task", {
|
|
334
|
-
parseXlsx(filePath) {
|
|
335
|
-
return new Promise((resolve, reject) => {
|
|
336
|
-
try {
|
|
337
|
-
const jsonData = parse(readFileSync(filePath));
|
|
338
|
-
resolve(jsonData);
|
|
339
|
-
}
|
|
340
|
-
catch (e) {
|
|
341
|
-
reject(e);
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
},
|
|
345
|
-
fileExists(filename) {
|
|
346
|
-
return existsSync(filename);
|
|
347
|
-
},
|
|
348
|
-
});
|
|
349
|
-
/* ---- END: Task setup ---- */
|
|
350
|
-
/* ---- BEGIN: codeowner setup ---- */
|
|
351
|
-
const codeowner = toShortTeamName(getCodeowner(config.projectRoot, config.nxRoot));
|
|
352
|
-
config.env.codeowner = codeowner;
|
|
353
|
-
/* ---- END: codeowner setup ---- */
|
|
354
|
-
/* ---- BEGIN: HAR setup ---- */
|
|
355
|
-
// Installing the HAR geneartor should happen last according to the documentation
|
|
356
|
-
// https://github.com/NeuraLegion/cypress-har-generator?tab=readme-ov-file#setting-up-the-plugin
|
|
357
|
-
installHarGenerator(on);
|
|
358
|
-
/* ---- END: HAR setup ---- */
|
|
359
|
-
return config;
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Creates the standard NX E2E preset configuration for Cypress.
|
|
364
|
-
* This wraps the @nx/cypress preset with our default Vite configuration.
|
|
365
|
-
*
|
|
366
|
-
* @param filename - Pass `__filename` from the calling cypress.config.ts
|
|
367
|
-
* @example
|
|
368
|
-
* ```ts
|
|
369
|
-
* import { createNxPreset, CypressPluginConfig, defaultCypressConfig, setupPlugins } from "@trackunit/iris-app-e2e";
|
|
370
|
-
* import { defineConfig } from "cypress";
|
|
371
|
-
*
|
|
372
|
-
* const nxPreset = createNxPreset(__filename);
|
|
373
|
-
*
|
|
374
|
-
* export default defineConfig({
|
|
375
|
-
* chromeWebSecurity: false,
|
|
376
|
-
* e2e: {
|
|
377
|
-
* ...nxPreset,
|
|
378
|
-
* ...defaultCypressConfig(__dirname),
|
|
379
|
-
* async setupNodeEvents(on, config: CypressPluginConfig) {
|
|
380
|
-
* await nxPreset.setupNodeEvents?.(on, config);
|
|
381
|
-
* return setupPlugins(on, config, formatter, installHarGenerator);
|
|
382
|
-
* },
|
|
383
|
-
* },
|
|
384
|
-
* });
|
|
385
|
-
* ```
|
|
386
|
-
*/
|
|
387
|
-
function createNxPreset(filename) {
|
|
388
|
-
return nxE2EPreset(filename, {
|
|
389
|
-
bundler: "vite",
|
|
390
|
-
cypressDir: "cypress",
|
|
391
|
-
viteConfigOverrides: {
|
|
392
|
-
configFile: false,
|
|
393
|
-
plugins: [nxViteTsPaths()],
|
|
394
|
-
},
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
export { createLogFile, createNxPreset, defaultCypressConfig, setupPlugins, writeFileWithPrettier };
|