pagean 16.1.1 → 16.2.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.
@@ -19,6 +19,7 @@ program
19
19
  .parse(process.argv);
20
20
  const options = program.opts();
21
21
 
22
+ // eslint-disable-next-line unicorn/consistent-boolean-name -- follow package convention
22
23
  const logError = (message, exitOnError = true) => {
23
24
  log({ errorCode: 1, exitOnError, level: Levels.Error, message });
24
25
  };
package/index.js CHANGED
@@ -87,6 +87,7 @@ const executeAllTests = async (config) => {
87
87
  const consoleLog = [];
88
88
  const page = await browser.newPage();
89
89
  page.on('console', (message) =>
90
+ // eslint-disable-next-line unicorn/no-return-array-push -- unused
90
91
  consoleLog.push({
91
92
  location: message.location(),
92
93
  text: message.text(),
package/lib/config.js CHANGED
@@ -43,8 +43,8 @@ const processAllTestSettings = (settings) => {
43
43
  return;
44
44
  }
45
45
  const processedSettings = {};
46
- for (const key of Object.keys(settings)) {
47
- processedSettings[key] = processTestSetting(settings[key]);
46
+ for (const [key, value] of Object.entries(settings)) {
47
+ processedSettings[key] = processTestSetting(value);
48
48
  }
49
49
  /* eslint-disable-next-line consistent-return -- return undefined
50
50
  if no settings */
@@ -59,9 +59,9 @@ const consolidateTestSettings = (
59
59
  const sanitizedGlobalSettings = globalSettings || {};
60
60
  const sanitizedUrlSettings = urlSettings || {};
61
61
  const processedSettings = {};
62
- for (const key of Object.keys(defaultSettings)) {
62
+ for (const [key, value] of Object.entries(defaultSettings)) {
63
63
  processedSettings[key] = {
64
- ...defaultSettings[key],
64
+ ...value,
65
65
  ...sanitizedGlobalSettings[key],
66
66
  ...sanitizedUrlSettings[key]
67
67
  };
@@ -126,7 +126,8 @@ const validateConfigSchema = (config) => {
126
126
  // All values hardcoded.
127
127
  // nosemgrep: eslint.detect-non-literal-fs-filename
128
128
  fs.readFileSync(
129
- path.join(__dirname, '..', 'schemas', 'pageanrc.schema.json')
129
+ path.join(__dirname, '..', 'schemas', 'pageanrc.schema.json'),
130
+ 'utf8'
130
131
  )
131
132
  );
132
133
  // Allow allErrors to lint the entire config file, although users could
@@ -126,18 +126,18 @@ const checkExternalPageLinkBrowser = async (page, link) => {
126
126
  };
127
127
 
128
128
  /**
129
- * Checks the provided link for validity by requesting with fetch. If useGet is false,
130
- * a HEAD request is made for efficiency. If useGet is true, a full GET request is made.
129
+ * Checks the provided link for validity by requesting with fetch. If shouldUseGet is false,
130
+ * a HEAD request is made for efficiency. If shouldUseGet is true, a full GET request is made.
131
131
  *
132
- * @param {Page} page A Puppeteer page object.
133
- * @param {string} link The link to check.
134
- * @param {boolean} [useGet] Used to identify the request method to use (HEAD or GET).
135
- * @returns {Promise<(string|number)>} The link status (HTTP response code or error).
132
+ * @param {Page} page A Puppeteer page object.
133
+ * @param {string} link The link to check.
134
+ * @param {boolean} [shouldUseGet] Used to identify the request method to use (HEAD or GET).
135
+ * @returns {Promise<(string|number)>} The link status (HTTP response code or error).
136
136
  * @static
137
137
  * @private
138
138
  */
139
139
  // eslint-disable-next-line complexity -- Allow low limit
140
- const checkExternalPageLink = async (page, link, useGet = false) => {
140
+ const checkExternalPageLink = async (page, link, shouldUseGet = false) => {
141
141
  if (link.startsWith('file:')) {
142
142
  return 'Cannot check "file:" URLs';
143
143
  }
@@ -148,7 +148,7 @@ const checkExternalPageLink = async (page, link, useGet = false) => {
148
148
  try {
149
149
  const fetchOptions = {
150
150
  headers: { 'User-Agent': userAgent },
151
- method: useGet ? 'GET' : 'HEAD',
151
+ method: shouldUseGet ? 'GET' : 'HEAD',
152
152
  signal: AbortSignal.timeout(timeoutSeconds * msPerSec)
153
153
  };
154
154
  // Using internal browser property since not exposed
@@ -165,7 +165,7 @@ const checkExternalPageLink = async (page, link, useGet = false) => {
165
165
  // that should skip a retry (e.g. 429), and the request was head then retry
166
166
  // with get.
167
167
  if (!response.ok) {
168
- if (!noRetryResponses.has(response.status) && !useGet) {
168
+ if (!noRetryResponses.has(response.status) && !shouldUseGet) {
169
169
  return checkExternalPageLink(page, link, true);
170
170
  }
171
171
  return response.status;
package/lib/logger.js CHANGED
@@ -28,7 +28,7 @@ const nullFunction = () => {};
28
28
  * @static
29
29
  */
30
30
  // eslint-disable-next-line max-lines-per-function -- factory function with state
31
- const factory = (config) => {
31
+ export default function factory(config) {
32
32
  const cliReporter = {
33
33
  // If cli reporter is enabled, set console log function, otherwise null function
34
34
  log: config.reporters.includes(reporterTypes.cli)
@@ -95,17 +95,19 @@ const factory = (config) => {
95
95
  * @param {object} testResult The test results object.
96
96
  */
97
97
  const logTestResults = (testResult) => {
98
- if (testResult) {
99
- currentUrlTests.tests.push(testResult);
100
- testResults.summary.tests++;
101
- testResults.summary[testResult.result]++;
102
-
103
- cliReporter.log({
104
- isResult: true,
105
- message: `${testResult.name} (${testResult.result})`,
106
- resultPrefix: testResultSymbols[testResult.result]
107
- });
98
+ if (!testResult) {
99
+ return;
108
100
  }
101
+
102
+ currentUrlTests.tests.push(testResult);
103
+ testResults.summary.tests++;
104
+ testResults.summary[testResult.result]++;
105
+
106
+ cliReporter.log({
107
+ isResult: true,
108
+ message: `${testResult.name} (${testResult.result})`,
109
+ resultPrefix: testResultSymbols[testResult.result]
110
+ });
109
111
  };
110
112
 
111
113
  const outputTestSummary = () => {
@@ -132,6 +134,4 @@ const factory = (config) => {
132
134
  logTestResults,
133
135
  startUrlTests
134
136
  };
135
- };
136
-
137
- export default factory;
137
+ }
package/lib/reporter.js CHANGED
@@ -15,6 +15,7 @@ const htmlReportTemplateName = 'report-template.handlebars';
15
15
  const htmlReportFileName = './pagean-results.html';
16
16
  const jsonReportFileName = './pagean-results.json';
17
17
 
18
+ // eslint-disable-next-line unicorn/no-top-level-side-effects -- package limitation
18
19
  handlebars.registerHelper('json', (context) =>
19
20
  // eslint-disable-next-line no-magic-numbers -- no-magic-numbers - count
20
21
  JSON.stringify(context, undefined, 2)
package/lib/sitemap.js CHANGED
@@ -86,7 +86,7 @@ const replaceUrlStrings = (urls, find, replace) => {
86
86
  if (!find || !replace) {
87
87
  return urls;
88
88
  }
89
- return urls.map((url) => url.replace(find, replace));
89
+ return urls.map((url) => url.replace(find, () => replace));
90
90
  };
91
91
 
92
92
  /**
package/lib/tests.js CHANGED
@@ -156,7 +156,7 @@ const pageLoadTimeTest = async (context) => {
156
156
  const performanceTiming = JSON.parse(
157
157
  await context.page.evaluate(() =>
158
158
  /* v8 ignore next: executed in browser */
159
- JSON.stringify(globalThis.performance)
159
+ JSON.stringify(performance)
160
160
  )
161
161
  );
162
162
  const loadTimeSec =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pagean",
3
- "version": "16.1.1",
3
+ "version": "16.2.0",
4
4
  "description": "Pagean is a web page analysis tool designed to automate tests requiring web pages to be loaded in a browser window (e.g. horizontal scrollbar, console errors)",
5
5
  "bin": {
6
6
  "pagean": "bin/pagean.js",
@@ -56,17 +56,17 @@
56
56
  },
57
57
  "homepage": "https://gitlab.com/gitlab-ci-utils/pagean",
58
58
  "devDependencies": {
59
- "@aarongoldenthal/eslint-config-standard": "46.0.3",
59
+ "@aarongoldenthal/eslint-config-standard": "47.0.0",
60
60
  "@aarongoldenthal/stylelint-config-standard": "24.0.0",
61
61
  "@vitest/coverage-v8": "4.1.9",
62
62
  "bin-tester": "8.0.0",
63
63
  "c8": "11.0.0",
64
- "eslint": "10.5.0",
65
- "globals": "17.6.0",
66
- "markdownlint-cli2": "0.22.1",
64
+ "eslint": "10.6.0",
65
+ "globals": "17.7.0",
66
+ "markdownlint-cli2": "0.23.0",
67
67
  "nyc": "18.0.0",
68
- "prettier": "3.8.4",
69
- "stylelint": "17.13.0",
68
+ "prettier": "3.9.4",
69
+ "stylelint": "17.14.0",
70
70
  "vitest": "4.1.9"
71
71
  },
72
72
  "dependencies": {
@@ -79,7 +79,7 @@
79
79
  "htmlhint": "1.9.2",
80
80
  "normalize-url": "9.0.1",
81
81
  "protocolify": "4.0.0",
82
- "puppeteer": "25.1.0",
82
+ "puppeteer": "25.3.0",
83
83
  "undici": "8.5.0",
84
84
  "xml2js": "0.6.2"
85
85
  }