pagean 16.1.1 → 16.2.1
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/bin/pageanrc-lint.js +1 -0
- package/index.js +1 -0
- package/lib/config.js +6 -5
- package/lib/link-utilities.js +10 -9
- package/lib/logger.js +12 -10
- package/lib/reporter.js +1 -0
- package/lib/sitemap.js +1 -1
- package/lib/tests.js +1 -1
- package/package.json +14 -14
package/bin/pageanrc-lint.js
CHANGED
|
@@ -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.
|
|
47
|
-
processedSettings[key] = processTestSetting(
|
|
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.
|
|
62
|
+
for (const [key, value] of Object.entries(defaultSettings)) {
|
|
63
63
|
processedSettings[key] = {
|
|
64
|
-
...
|
|
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
|
package/lib/link-utilities.js
CHANGED
|
@@ -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
|
|
130
|
-
* a HEAD request is made for efficiency. If
|
|
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
|
|
133
|
-
* @param {string} link
|
|
134
|
-
* @param {boolean} [
|
|
135
|
-
* @returns {Promise<(string|number)>}
|
|
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,
|
|
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:
|
|
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,8 @@ 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
|
-
|
|
168
|
+
// eslint-disable-next-line unicorn/prefer-simple-condition-first -- more efficient
|
|
169
|
+
if (!noRetryResponses.has(response.status) && !shouldUseGet) {
|
|
169
170
|
return checkExternalPageLink(page, link, true);
|
|
170
171
|
}
|
|
171
172
|
return response.status;
|
package/lib/logger.js
CHANGED
|
@@ -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
|
-
|
|
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 = () => {
|
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
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(
|
|
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.
|
|
3
|
+
"version": "16.2.1",
|
|
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",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"hooks:pre-commit": "npm run lint && npm run prettier:check",
|
|
12
|
-
"hooks:pre-push": "npm audit --audit-level=
|
|
12
|
+
"hooks:pre-push": "npm audit --audit-level=critical && npm test",
|
|
13
13
|
"lint": "npm run lint:css && npm run lint:html && npm run lint:js && npm run lint:md",
|
|
14
14
|
"lint:css": "stylelint ./lib/report-template.handlebars",
|
|
15
15
|
"lint:html": "htmlhint ./lib/report-template.handlebars",
|
|
@@ -56,31 +56,31 @@
|
|
|
56
56
|
},
|
|
57
57
|
"homepage": "https://gitlab.com/gitlab-ci-utils/pagean",
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@aarongoldenthal/eslint-config-standard": "
|
|
59
|
+
"@aarongoldenthal/eslint-config-standard": "48.0.0",
|
|
60
60
|
"@aarongoldenthal/stylelint-config-standard": "24.0.0",
|
|
61
|
-
"@vitest/coverage-v8": "4.1.
|
|
61
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
62
62
|
"bin-tester": "8.0.0",
|
|
63
|
-
"c8": "
|
|
64
|
-
"eslint": "10.
|
|
65
|
-
"globals": "17.
|
|
66
|
-
"markdownlint-cli2": "0.
|
|
63
|
+
"c8": "12.0.0",
|
|
64
|
+
"eslint": "10.8.0",
|
|
65
|
+
"globals": "17.8.0",
|
|
66
|
+
"markdownlint-cli2": "0.23.1",
|
|
67
67
|
"nyc": "18.0.0",
|
|
68
|
-
"prettier": "3.
|
|
69
|
-
"stylelint": "17.
|
|
70
|
-
"vitest": "4.1.
|
|
68
|
+
"prettier": "3.9.6",
|
|
69
|
+
"stylelint": "17.14.1",
|
|
70
|
+
"vitest": "4.1.10"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"ajv": "8.20.0",
|
|
74
74
|
"ajv-errors": "3.0.0",
|
|
75
|
-
"ci-logger": "9.0.
|
|
75
|
+
"ci-logger": "9.0.1",
|
|
76
76
|
"commander": "15.0.0",
|
|
77
77
|
"cssesc": "3.0.0",
|
|
78
78
|
"handlebars": "4.7.9",
|
|
79
79
|
"htmlhint": "1.9.2",
|
|
80
80
|
"normalize-url": "9.0.1",
|
|
81
81
|
"protocolify": "4.0.0",
|
|
82
|
-
"puppeteer": "25.
|
|
83
|
-
"undici": "8.
|
|
82
|
+
"puppeteer": "25.3.0",
|
|
83
|
+
"undici": "8.9.0",
|
|
84
84
|
"xml2js": "0.6.2"
|
|
85
85
|
}
|
|
86
86
|
}
|