pagean 4.4.2 → 6.0.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/LICENSE +1 -1
- package/README.md +9 -9
- package/docs/upgrade-guide.md +16 -0
- package/index.js +7 -4
- package/lib/config.js +2 -2
- package/lib/default-config.json +41 -39
- package/lib/externalFileUtils.js +1 -1
- package/lib/linkUtils.js +162 -25
- package/lib/logger.js +1 -1
- package/lib/report-template.handlebars +224 -209
- package/lib/schemaErrors.js +5 -4
- package/lib/testUtils.js +1 -1
- package/lib/tests.js +14 -14
- package/package.json +28 -30
- package/schemas/pageanrc.schema.json +199 -191
- package/.codeclimate.json +0 -8
- package/.depcheckrc.json +0 -3
- package/.dockerignore +0 -12
- package/.eslintrc.json +0 -19
- package/.gitattributes +0 -4
- package/.gitlab/gitlab-releaser.json +0 -16
- package/.htmlhintrc +0 -25
- package/.markdownlint.json +0 -13
- package/.pa11yci.json +0 -5
- package/.pageanrc.json +0 -55
- package/.stylelintrc.json +0 -7
- package/CHANGELOG.md +0 -204
- package/gitlab.pageanrc.json +0 -16
- package/jest.config.json +0 -22
- package/static-server.pageanrc.json +0 -50
- package/tests/__snapshots__/config.test.js.snap +0 -591
- package/tests/__snapshots__/externalFileUtils.test.js.snap +0 -7
- package/tests/__snapshots__/index.test.js.snap +0 -30
- package/tests/__snapshots__/pagean.test.js.snap +0 -82
- package/tests/__snapshots__/pageanrc.test.js.snap +0 -759
- package/tests/__snapshots__/reporter.test.js.snap +0 -509
- package/tests/config.test.js +0 -264
- package/tests/externalFileUtils.test.js +0 -184
- package/tests/index.test.js +0 -181
- package/tests/linkUtils.test.js +0 -290
- package/tests/logger.test.js +0 -324
- package/tests/pagean.test.js +0 -85
- package/tests/pageanrc.test.js +0 -96
- package/tests/reporter.test.js +0 -82
- package/tests/schemaErrors.test.js +0 -88
- package/tests/test-cases/.htmlhintrc +0 -25
- package/tests/test-cases/brokenLinks.html +0 -22
- package/tests/test-cases/consoleLog.html +0 -11
- package/tests/test-cases/duplicateLinks.html +0 -22
- package/tests/test-cases/dynamicContent.html +0 -13
- package/tests/test-cases/externalScripts.html +0 -21
- package/tests/test-cases/horizontalScrollbar.html +0 -13
- package/tests/test-cases/htmlError.html +0 -11
- package/tests/test-cases/noExternalScripts.html +0 -12
- package/tests/test-cases/notDocumentLinks.html +0 -18
- package/tests/test-cases/pagean-results.json +0 -1
- package/tests/test-cases/scriptError404.html +0 -9
- package/tests/test-cases/slowLoad.html +0 -9
- package/tests/test-configs/cli-tests/.pageanrc.json +0 -28
- package/tests/test-configs/cli-tests/all-empty.pageanrc.json +0 -10
- package/tests/test-configs/cli-tests/all-errors.pageanrc.json +0 -69
- package/tests/test-configs/cli-tests/all-fail-cli.pageanrc.json +0 -9
- package/tests/test-configs/cli-tests/no-urls.pageanrc.json +0 -7
- package/tests/test-configs/cli-tests/pass-fail-cli.pageanrc.json +0 -14
- package/tests/test-configs/integration-tests/all-passing-tests.pageanrc.json +0 -63
- package/tests/test-configs/integration-tests/broken-links-error.pageanrc.json +0 -22
- package/tests/test-configs/integration-tests/console-error-reporter-cli-json.pageanrc.json +0 -20
- package/tests/test-configs/integration-tests/console-error-reporter-html.pageanrc.json +0 -19
- package/tests/test-configs/integration-tests/console-error.pageanrc.json +0 -16
- package/tests/test-configs/integration-tests/console-output.pageanrc.json +0 -16
- package/tests/test-configs/integration-tests/external-scripts-error.pageanrc.json +0 -19
- package/tests/test-configs/integration-tests/horizontal-scrollbar.pageanrc.json +0 -16
- package/tests/test-configs/integration-tests/html-error.pageanrc.json +0 -16
- package/tests/test-configs/integration-tests/page-load-time.pageanrc.json +0 -16
- package/tests/test-configs/unit-tests/empty-url-values.pageanrc.json +0 -9
- package/tests/test-configs/unit-tests/empty-urls.pageanrc.json +0 -3
- package/tests/test-configs/unit-tests/empty.pageanrc.json +0 -2
- package/tests/test-configs/unit-tests/global-and-test-specific-settings-shorthand.pageanrc.json +0 -30
- package/tests/test-configs/unit-tests/global-and-test-specific-settings-test-props.pageanrc.json +0 -42
- package/tests/test-configs/unit-tests/global-and-test-specific-settings.pageanrc.json +0 -34
- package/tests/test-configs/unit-tests/global-test-settings.pageanrc.json +0 -15
- package/tests/test-configs/unit-tests/htmlhintrc-invalid.pageanrc.json +0 -7
- package/tests/test-configs/unit-tests/htmlhintrc-valid.pageanrc.json +0 -7
- package/tests/test-configs/unit-tests/ignored-links-denormalized.pageanrc.json +0 -18
- package/tests/test-configs/unit-tests/invalid.pageanrc.json +0 -0
- package/tests/test-configs/unit-tests/no-test-settings.pageanrc.json +0 -6
- package/tests/test-configs/unit-tests/project-no-test-settings.pageanrc.json +0 -7
- package/tests/test-configs/unit-tests/puppeteer-no-test-settings.pageanrc.json +0 -9
- package/tests/test-configs/unit-tests/reporters-empty.pageanrc.json +0 -7
- package/tests/test-configs/unit-tests/reporters-invalid-type.pageanrc.json +0 -9
- package/tests/test-configs/unit-tests/reporters-not-array.pageanrc.json +0 -6
- package/tests/test-configs/unit-tests/reporters-valid.pageanrc.json +0 -9
- package/tests/test-configs/unit-tests/test-specific-settings.pageanrc.json +0 -26
- package/tests/test-configs/unit-tests/url-types.pageanrc.json +0 -10
- package/tests/testUtils.test.js +0 -244
- package/tests/tests.test.js +0 -533
package/tests/pagean.test.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const bin = require('bin-tester'); // eslint-disable-line node/no-unpublished-require
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line max-lines-per-function
|
|
7
|
-
describe('pagean CLI', () => {
|
|
8
|
-
const testDir = path.join('./', 'tests', 'test-configs', 'cli-tests');
|
|
9
|
-
const defaultConfigFileName = '.pageanrc.json';
|
|
10
|
-
const allFailConfigFileName = 'all-fail-cli.pageanrc.json';
|
|
11
|
-
const invalidConfigFileName = 'no-urls.pageanrc.json';
|
|
12
|
-
const passFailConfigFileName = 'pass-fail-cli.pageanrc.json';
|
|
13
|
-
const missingConfigFileName = 'foo.pageanrc.json';
|
|
14
|
-
|
|
15
|
-
const executePageanBinTest = async(args, expectedResults) => {
|
|
16
|
-
expect.assertions(Object.keys(expectedResults).length);
|
|
17
|
-
|
|
18
|
-
const results = await bin(args, testDir, undefined, undefined, 'pagean');
|
|
19
|
-
|
|
20
|
-
expect(results.code).toStrictEqual(expectedResults.code);
|
|
21
|
-
if (expectedResults.error) {
|
|
22
|
-
expect(results.error.message).toMatch(expectedResults.error);
|
|
23
|
-
}
|
|
24
|
-
if (expectedResults.stderr) {
|
|
25
|
-
expect(results.stderr).toMatch(expectedResults.stderr);
|
|
26
|
-
}
|
|
27
|
-
if (expectedResults.stdout) {
|
|
28
|
-
expectedResults.stdout === 'SNAPSHOT'
|
|
29
|
-
? expect(results.stdout).toMatchSnapshot()
|
|
30
|
-
: expect(results.stdout).toMatch(expectedResults.stdout);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
it(`should default to ${defaultConfigFileName} if no config file specified via CLI`, async() => {
|
|
35
|
-
expect.hasAssertions();
|
|
36
|
-
const args = [];
|
|
37
|
-
const expectedResults = {
|
|
38
|
-
code: 0,
|
|
39
|
-
stdout: 'SNAPSHOT'
|
|
40
|
-
};
|
|
41
|
-
await executePageanBinTest(args, expectedResults);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should use correct config file if specified via CLI option (--config)', async() => {
|
|
45
|
-
expect.hasAssertions();
|
|
46
|
-
const args = ['--config', passFailConfigFileName];
|
|
47
|
-
const expectedResults = {
|
|
48
|
-
code: 1,
|
|
49
|
-
stdout: 'SNAPSHOT'
|
|
50
|
-
};
|
|
51
|
-
await executePageanBinTest(args, expectedResults);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should use correct config file if specified via CLI option shorthand (-c)', async() => {
|
|
55
|
-
expect.hasAssertions();
|
|
56
|
-
const args = ['-c', allFailConfigFileName];
|
|
57
|
-
const expectedResults = {
|
|
58
|
-
code: 1,
|
|
59
|
-
stdout: 'SNAPSHOT'
|
|
60
|
-
};
|
|
61
|
-
await executePageanBinTest(args, expectedResults);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should exit with error if specified config file cannot be found', async() => {
|
|
65
|
-
expect.hasAssertions();
|
|
66
|
-
const args = ['-c', missingConfigFileName];
|
|
67
|
-
const expectedResults = {
|
|
68
|
-
code: 1,
|
|
69
|
-
error: 'ENOENT',
|
|
70
|
-
stderr: 'Error executing pagean tests'
|
|
71
|
-
};
|
|
72
|
-
await executePageanBinTest(args, expectedResults);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should exit with error if specified config file is invalid', async() => {
|
|
76
|
-
expect.hasAssertions();
|
|
77
|
-
const args = ['-c', invalidConfigFileName];
|
|
78
|
-
const expectedResults = {
|
|
79
|
-
code: 1,
|
|
80
|
-
error: 'invalid pageanrc schema',
|
|
81
|
-
stderr: 'Error executing pagean tests'
|
|
82
|
-
};
|
|
83
|
-
await executePageanBinTest(args, expectedResults);
|
|
84
|
-
});
|
|
85
|
-
});
|
package/tests/pageanrc.test.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const bin = require('bin-tester'); // eslint-disable-line node/no-unpublished-require
|
|
4
|
-
const stripAnsi = require('strip-ansi'); // eslint-disable-line node/no-unpublished-require
|
|
5
|
-
|
|
6
|
-
// These names do not use path.join since these names resolve in all OSs, and are
|
|
7
|
-
// included in snapshots. With path.join there would be a Linux/Windows mismatch
|
|
8
|
-
// in tests (the snapshots matching the OS they were created in).
|
|
9
|
-
const cliTestFolder = './tests/test-configs/cli-tests';
|
|
10
|
-
const defaultConfigFileName = '.pageanrc.json';
|
|
11
|
-
const nonExistentConfigFileName = 'not-a-file.json';
|
|
12
|
-
const invalidConfigFileName = './tests/test-configs/unit-tests/invalid.pageanrc.json';
|
|
13
|
-
const emptyConfigFileName = './tests/test-configs/unit-tests/empty.pageanrc.json';
|
|
14
|
-
const allEmptyConfigFileName = './tests/test-configs/cli-tests/all-empty.pageanrc.json';
|
|
15
|
-
const allErrorsConfigFileName = './tests/test-configs/cli-tests/all-errors.pageanrc.json';
|
|
16
|
-
|
|
17
|
-
const errorMessage = 'Error linting pageanrc file';
|
|
18
|
-
const lintCommand = 'pageanrc-lint';
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line max-lines-per-function
|
|
21
|
-
describe('pageanrc lint', () => {
|
|
22
|
-
const testLintInvalidFiles = async(args, message) => {
|
|
23
|
-
expect.assertions(3); // eslint-disable-line no-magic-numbers
|
|
24
|
-
const result = await bin(args, undefined, undefined, undefined, lintCommand);
|
|
25
|
-
expect(result.code).toStrictEqual(1);
|
|
26
|
-
expect(result.error.message).toMatch(message);
|
|
27
|
-
expect(result.stderr).toMatch(errorMessage);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
it('should return an error and exit for a non existent pageanrc file', async() => {
|
|
31
|
-
expect.hasAssertions();
|
|
32
|
-
const args = [nonExistentConfigFileName];
|
|
33
|
-
await testLintInvalidFiles(args, 'ENOENT');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should return an error and exit for an invalid pageanrc file', async() => {
|
|
37
|
-
expect.hasAssertions();
|
|
38
|
-
const args = [invalidConfigFileName];
|
|
39
|
-
await testLintInvalidFiles(args, 'Unexpected end of JSON input');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const testLintWithErrorSnapshot = async(args) => {
|
|
43
|
-
expect.assertions(1);
|
|
44
|
-
const result = await bin(args, undefined, undefined, undefined, lintCommand);
|
|
45
|
-
// Strip ansi escape codes since not serialized in jest snapshots
|
|
46
|
-
expect(stripAnsi(result.stderr)).toMatchSnapshot();
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const testLintWithOutputSnapshot = async(args) => {
|
|
50
|
-
expect.assertions(1);
|
|
51
|
-
const result = await bin(args, undefined, undefined, undefined, lintCommand);
|
|
52
|
-
expect(result.stdout).toMatchSnapshot();
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
it('should lint the pageanrc file specified as argument', async() => {
|
|
56
|
-
expect.hasAssertions();
|
|
57
|
-
const result = await bin([allErrorsConfigFileName], undefined, undefined, undefined, lintCommand);
|
|
58
|
-
expect(result.stderr).toMatch(allErrorsConfigFileName);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should lint the default file if none specified', async() => {
|
|
62
|
-
expect.assertions(1);
|
|
63
|
-
const result = await bin([], cliTestFolder, undefined, undefined, lintCommand);
|
|
64
|
-
expect(result.stdout).toMatch(defaultConfigFileName);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should lint the all errors pageanrc and return all CLI errors', async() => {
|
|
68
|
-
expect.hasAssertions();
|
|
69
|
-
const args = [allErrorsConfigFileName];
|
|
70
|
-
await testLintWithErrorSnapshot(args);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should lint the all empty pageanrc and return all CLI errors', async() => {
|
|
74
|
-
expect.hasAssertions();
|
|
75
|
-
const args = [allEmptyConfigFileName];
|
|
76
|
-
await testLintWithErrorSnapshot(args);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should lint the empty pageanrc and return all CLI errors', async() => {
|
|
80
|
-
expect.hasAssertions();
|
|
81
|
-
const args = [emptyConfigFileName];
|
|
82
|
-
await testLintWithErrorSnapshot(args);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should lint the all errors pageanrc and return all JSON errors to stdout with -j option', async() => {
|
|
86
|
-
expect.hasAssertions();
|
|
87
|
-
const args = ['-j', allErrorsConfigFileName];
|
|
88
|
-
await testLintWithOutputSnapshot(args);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should lint the all empty pageanrc and return all JSON errors to stdout with --json option', async() => {
|
|
92
|
-
expect.hasAssertions();
|
|
93
|
-
const args = ['--json', allEmptyConfigFileName];
|
|
94
|
-
await testLintWithOutputSnapshot(args);
|
|
95
|
-
});
|
|
96
|
-
});
|
package/tests/reporter.test.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
const reporter = require('../lib/reporter');
|
|
7
|
-
const defaultReporters = require('../lib/default-config.json').reporters;
|
|
8
|
-
|
|
9
|
-
const htmlReportFileName = './pagean-results.html';
|
|
10
|
-
const jsonReportRawFileName = 'pagean-results.json';
|
|
11
|
-
const jsonReportFileName = `./${jsonReportRawFileName}`;
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line max-lines-per-function
|
|
14
|
-
describe('reporter', () => {
|
|
15
|
-
const saveReportTest = (fileName, reporters, saveFile = true) => {
|
|
16
|
-
const testResults = {};
|
|
17
|
-
const writeFileSpy = jest.spyOn(fs, 'writeFileSync').mockImplementation(() => {});
|
|
18
|
-
|
|
19
|
-
reporter.saveReports(testResults, reporters);
|
|
20
|
-
|
|
21
|
-
if (saveFile) {
|
|
22
|
-
expect(writeFileSpy).toHaveBeenCalledWith(fileName, expect.any(String));
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
expect(writeFileSpy).not.toHaveBeenCalledWith(fileName, expect.any(String));
|
|
26
|
-
}
|
|
27
|
-
return writeFileSpy.mock.calls[0][1];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
afterEach(() => {
|
|
31
|
-
jest.restoreAllMocks();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should save HTML report file if specified in reporters', () => {
|
|
35
|
-
expect.assertions(1);
|
|
36
|
-
const reporters = ['html'];
|
|
37
|
-
saveReportTest(htmlReportFileName, reporters, true);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should not save HTML report file if not specified in reporters', () => {
|
|
41
|
-
expect.assertions(1);
|
|
42
|
-
const reporters = ['json'];
|
|
43
|
-
saveReportTest(htmlReportFileName, reporters, false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should save JSON report file if specified in reporters', () => {
|
|
47
|
-
expect.assertions(1);
|
|
48
|
-
const reporters = ['json'];
|
|
49
|
-
saveReportTest(jsonReportFileName, reporters, true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should not save JSON report file if not specified in reporters', () => {
|
|
53
|
-
expect.assertions(1);
|
|
54
|
-
const reporters = ['html'];
|
|
55
|
-
saveReportTest(jsonReportFileName, reporters, false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should save JSON report with valid JSON', () => {
|
|
59
|
-
expect.assertions(2); // eslint-disable-line no-magic-numbers
|
|
60
|
-
const reportContents = saveReportTest(jsonReportFileName, defaultReporters);
|
|
61
|
-
expect(() => JSON.parse(reportContents)).not.toThrow();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should write expected JSON and HTML reports', () => {
|
|
65
|
-
expect.assertions(3); // eslint-disable-line no-magic-numbers
|
|
66
|
-
const reportCount = 2;
|
|
67
|
-
const jsonReportFile = path.join('tests', 'test-cases', jsonReportRawFileName);
|
|
68
|
-
const testResults = JSON.parse(fs.readFileSync(jsonReportFile, 'utf-8'));
|
|
69
|
-
const writeFileSpy = jest.spyOn(fs, 'writeFileSync').mockImplementation(() => {});
|
|
70
|
-
|
|
71
|
-
reporter.saveReports(testResults, defaultReporters);
|
|
72
|
-
|
|
73
|
-
expect(writeFileSpy).toHaveBeenCalledTimes(reportCount);
|
|
74
|
-
// eslint-disable-next-line prefer-destructuring -- less intuitive
|
|
75
|
-
const jsonReport = writeFileSpy.mock.calls[0][1];
|
|
76
|
-
expect(jsonReport).toMatchSnapshot();
|
|
77
|
-
|
|
78
|
-
// eslint-disable-next-line prefer-destructuring -- less intuitive
|
|
79
|
-
const htmlReport = writeFileSpy.mock.calls[1][1];
|
|
80
|
-
expect(htmlReport).toMatchSnapshot();
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { red } = require('kleur');
|
|
4
|
-
const { formatErrors } = require('../lib/schemaErrors');
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line max-lines-per-function
|
|
7
|
-
describe('schema errors', () => {
|
|
8
|
-
const baseKey = '<pageanrc>';
|
|
9
|
-
const errors = [
|
|
10
|
-
{
|
|
11
|
-
keyword: 'minProperties',
|
|
12
|
-
dataPath: '/puppeteerLaunchOptions',
|
|
13
|
-
schemaPath: '#/properties/puppeteerLaunchOptions/minProperties',
|
|
14
|
-
params: { limit: 1 },
|
|
15
|
-
message: 'should NOT have fewer than 1 items'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
keyword: 'enum',
|
|
19
|
-
dataPath: '/reporters/0',
|
|
20
|
-
schemaPath: '#/properties/reporters/items/enum',
|
|
21
|
-
params: { allowedValues: ['cli', 'html', 'json'] },
|
|
22
|
-
message: 'should be equal to one of the allowed values'
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
const getValuesFromErrorMessage = error => {
|
|
27
|
-
const results = error.trim().split(' ').filter(str => str !== '');
|
|
28
|
-
return { dataKey: results[0], message: results[1] };
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
it('should return array of error strings', () => {
|
|
32
|
-
expect.assertions(3); // eslint-disable-line no-magic-numbers
|
|
33
|
-
const results = formatErrors(errors);
|
|
34
|
-
expect(Array.isArray(results)).toStrictEqual(true);
|
|
35
|
-
results.forEach(result => expect(typeof(result)).toStrictEqual('string'));
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should format error strings with only data key and error message', () => {
|
|
39
|
-
expect.assertions(3); // eslint-disable-line no-magic-numbers
|
|
40
|
-
const results = formatErrors(errors);
|
|
41
|
-
const { dataKey, message, ...values } = getValuesFromErrorMessage(results[0]);
|
|
42
|
-
// Check that dataKey and message match the appropriate text, and there are no
|
|
43
|
-
// other values in error message. Detailed formatting is checked in other tests.
|
|
44
|
-
expect(dataKey).toMatch(errors[0].dataPath.replace('/', ''));
|
|
45
|
-
expect(message).toMatch(errors[0].message);
|
|
46
|
-
expect(values).toStrictEqual({});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should format error strings with red text for error message', () => {
|
|
50
|
-
expect.assertions(1);
|
|
51
|
-
const results = formatErrors(errors);
|
|
52
|
-
const { message } = getValuesFromErrorMessage(results[0]);
|
|
53
|
-
expect(message).toStrictEqual(red(errors[0].message));
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('should convert dataPath from JSON pointer to data key', () => {
|
|
57
|
-
expect.assertions(1);
|
|
58
|
-
const results = formatErrors(errors);
|
|
59
|
-
const { dataKey } = getValuesFromErrorMessage(results[1]);
|
|
60
|
-
expect(dataKey).toStrictEqual(`${baseKey}.reporters[0]`);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should convert empty dataPath to base data key', () => {
|
|
64
|
-
expect.assertions(1);
|
|
65
|
-
const data = [{ dataPath: '', message: 'Error message', params: {} }];
|
|
66
|
-
const results = formatErrors(data);
|
|
67
|
-
const { dataKey } = getValuesFromErrorMessage(results[0]);
|
|
68
|
-
expect(dataKey).toStrictEqual(baseKey);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should convert root dataPath to base data key', () => {
|
|
72
|
-
expect.assertions(1);
|
|
73
|
-
const data = [{ dataPath: '/', message: 'Error message', params: {} }];
|
|
74
|
-
const results = formatErrors(data);
|
|
75
|
-
const { dataKey } = getValuesFromErrorMessage(results[0]);
|
|
76
|
-
expect(dataKey).toStrictEqual(baseKey);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should format error messages for invalid enums with valid values', () => {
|
|
80
|
-
expect.assertions(2);// eslint-disable-line no-magic-numbers
|
|
81
|
-
const results = formatErrors(errors);
|
|
82
|
-
const { message } = getValuesFromErrorMessage(results[1]);
|
|
83
|
-
const [, error] = errors;
|
|
84
|
-
expect(message).toMatch(error.message);
|
|
85
|
-
const allowedValue = error.params.allowedValues.join(', ');
|
|
86
|
-
expect(message).toMatch(allowedValue);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tagname-lowercase": true,
|
|
3
|
-
"attr-lowercase": true,
|
|
4
|
-
"attr-value-double-quotes": false,
|
|
5
|
-
"attr-value-not-empty": false,
|
|
6
|
-
"attr-no-duplication": true,
|
|
7
|
-
"doctype-first": true,
|
|
8
|
-
"tag-pair": true,
|
|
9
|
-
"empty-tag-not-self-closed": true,
|
|
10
|
-
"spec-char-escape": true,
|
|
11
|
-
"id-unique": true,
|
|
12
|
-
"src-not-empty": true,
|
|
13
|
-
"title-require": false,
|
|
14
|
-
"alt-require": true,
|
|
15
|
-
"doctype-html5": true,
|
|
16
|
-
"id-class-value": "false",
|
|
17
|
-
"style-disabled": false,
|
|
18
|
-
"inline-style-disabled": true,
|
|
19
|
-
"inline-script-disabled": false,
|
|
20
|
-
"space-tab-mixed-disabled": "space",
|
|
21
|
-
"id-class-ad-disabled": false,
|
|
22
|
-
"href-abs-or-rel": false,
|
|
23
|
-
"attr-unsafe-chars": true,
|
|
24
|
-
"head-script-disabled": true
|
|
25
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Broken Link Test</title>
|
|
5
|
-
<style>
|
|
6
|
-
ul {
|
|
7
|
-
padding-bottom: 1000px;
|
|
8
|
-
}
|
|
9
|
-
</style>
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<ul>
|
|
13
|
-
<li><a href="consoleLog.html">Console Log</a></li>
|
|
14
|
-
<li><a href="https://www.google.com">Google</a></li>
|
|
15
|
-
<li><a href="#linked">Linked content</a></li>
|
|
16
|
-
<li><a href="#notlinked">Not linked content</a></li>
|
|
17
|
-
<li><a href="https://this.url.does.not.exist">Does Not Exist</a></li>
|
|
18
|
-
<li><a href="https://this.url.is.ignored">Ignored Link</a></li>
|
|
19
|
-
</ul>
|
|
20
|
-
<div id="linked">This is linked content (<a href="#">top</a>)</div>
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Duplicate Link Test</title>
|
|
5
|
-
<style>
|
|
6
|
-
ul {
|
|
7
|
-
padding-bottom: 1000px;
|
|
8
|
-
}
|
|
9
|
-
</style>
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<ul>
|
|
13
|
-
<li><a href="https://www.google.com">Google</a></li>
|
|
14
|
-
<li><a href="#linked">Linked content</a></li>
|
|
15
|
-
<li><a href="#notlinked">Not linked content</a></li>
|
|
16
|
-
<li><a href="https://this.url.does.not.exist">Does Not Exist</a></li>
|
|
17
|
-
<li><a href="https://www.google.com">Google</a></li>
|
|
18
|
-
<li><a href="#linked">Linked content</a></li>
|
|
19
|
-
</ul>
|
|
20
|
-
<div id="linked">This is linked content (<a href="#">top</a>)</div>
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
</head>
|
|
5
|
-
<body>
|
|
6
|
-
<div id="content"></div>
|
|
7
|
-
<script>
|
|
8
|
-
const title = document.createElement('title');
|
|
9
|
-
title.innerText = 'Dynamic Content Test';
|
|
10
|
-
document.getElementsByTagName("head")[0].appendChild(title);
|
|
11
|
-
</script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>External Script Test</title>
|
|
5
|
-
</head>
|
|
6
|
-
<body>
|
|
7
|
-
<main>
|
|
8
|
-
<div id="content">This is some content.</div>
|
|
9
|
-
</main>
|
|
10
|
-
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8=" crossorigin="anonymous"></script>
|
|
11
|
-
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
|
12
|
-
<script src="//bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
|
|
13
|
-
<script src="test.js"></script>
|
|
14
|
-
<script>
|
|
15
|
-
document.getElementById('content').setAttribute("style", "color: red;");
|
|
16
|
-
const s = [...document.querySelectorAll("script[src]")].map(s => s.src);
|
|
17
|
-
console.log(s);
|
|
18
|
-
</script>
|
|
19
|
-
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8=" crossorigin="anonymous"></script>
|
|
20
|
-
</body>
|
|
21
|
-
</html>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Not Document Link Test</title>
|
|
5
|
-
<style>
|
|
6
|
-
ul {
|
|
7
|
-
padding-bottom: 1000px;
|
|
8
|
-
}
|
|
9
|
-
</style>
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<ul>
|
|
13
|
-
<li><a href="tel:+1.867.5309">867.5309/Jenny</a></li>
|
|
14
|
-
<li><a href="mailto:someone@place.com">someone@place.com</a></li>
|
|
15
|
-
<li><a href="javascript:alert('hi')">Javascript alert link</a></li>
|
|
16
|
-
</ul>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"project":"Pagean","executionStart":"2020-12-26T01:39:09.777Z","summary":{"tests":37,"passed":31,"warning":1,"failed":5},"results":[{"url":"tests/test-cases/consoleLog.html","tests":[{"name":"should not have console errors","result":"passed"},{"name":"should not have console output","result":"failed","data":[{"_type":"log","_text":"This is a test"}]},{"name":"should not have a horizontal scrollbar","result":"passed"},{"name":"should load page within 3 sec","result":"passed"},{"name":"should have valid rendered HTML","result":"passed"},{"name":"should not have external scripts","result":"passed"}]},{"url":"tests/test-cases/dynamicContent.html","tests":[{"name":"should not have console errors","result":"passed"},{"name":"should not have console output","result":"passed"},{"name":"should not have a horizontal scrollbar","result":"passed"},{"name":"should load page within 3 sec","result":"passed"},{"name":"should have valid rendered HTML","result":"passed"},{"name":"should not have external scripts","result":"passed"}]},{"url":"tests/test-cases/horizontalScrollbar.html","tests":[{"name":"should not have console errors","result":"passed"},{"name":"should not have console output","result":"passed"},{"name":"should not have a horizontal scrollbar","result":"failed"},{"name":"should load page within 3 sec","result":"passed"},{"name":"should have valid rendered HTML","result":"passed"},{"name":"should not have external scripts","result":"passed"}]},{"url":"tests/test-cases/htmlError.html","tests":[{"name":"should not have console errors","result":"passed"},{"name":"should not have console output","result":"passed"},{"name":"should not have a horizontal scrollbar","result":"passed"},{"name":"should load page within 3 sec","result":"passed"},{"name":"should have valid rendered HTML","result":"failed","data":[{"type":"error","message":"The id value [ div1 ] must be unique.","raw":" id=\"div1\"","evidence":" <div id=\"div1\"></div>","line":6,"col":9,"rule":{"id":"id-unique","description":"The value of id attributes must be unique.","link":"https://github.com/thedaviddias/HTMLHint/wiki/id-unique"}},{"type":"warning","message":"An alt attribute must be present on <img> elements.","raw":"<img>","evidence":" <img>","line":7,"col":9,"rule":{"id":"alt-require","description":"The alt attribute of an <img> element must be present and alt attribute of area[href] and input[type=image] must have a value.","link":"https://github.com/thedaviddias/HTMLHint/wiki/alt-require"}}]},{"name":"should not have external scripts","result":"passed"}]},{"url":"tests/test-cases/scriptError404.html","tests":[{"name":"should not have console errors","result":"failed","data":[{"_type":"error","_text":"Failed to load resource: net::ERR_NAME_NOT_RESOLVED"}]},{"name":"should not have a horizontal scrollbar","result":"passed"},{"name":"should load page within 3 sec","result":"passed"},{"name":"should have valid rendered HTML","result":"passed"}]},{"url":"tests/test-cases/slowLoad.html","tests":[{"name":"should not have console errors","result":"passed"},{"name":"should not have console output","result":"passed"},{"name":"should not have a horizontal scrollbar","result":"passed"},{"name":"should load page within 2 sec","result":"failed","data":{"pageLoadTime":2.842}},{"name":"should have valid rendered HTML","result":"passed"}]},{"url":"tests/test-cases/externalScripts.html","tests":[{"name":"should not have a horizontal scrollbar","result":"passed"},{"name":"should load page within 3 sec","result":"passed"},{"name":"should have valid rendered HTML","result":"passed"},{"name":"should not have external scripts","result":"warning","data":[{"url":"https://code.jquery.com/jquery-3.4.1.slim.min.js","localFile":"pagean-external-scripts\\code.jquery.com\\jquery-3.4.1.slim.min.js"},{"url":"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js","localFile":"pagean-external-scripts\\cdn.jsdelivr.net\\npm\\popper.js@1.16.0\\dist\\umd\\popper.min.js"},{"url":"file://bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js","error":"Request failed with status code 404"},{"url":"https://code.jquery.com/jquery-3.4.1.slim.min.js","localFile":"pagean-external-scripts\\code.jquery.com\\jquery-3.4.1.slim.min.js"}]}]}]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"reporters": [
|
|
3
|
-
"cli"
|
|
4
|
-
],
|
|
5
|
-
"settings": {
|
|
6
|
-
"horizontalScrollbarTest": true,
|
|
7
|
-
"consoleOutputTest": true,
|
|
8
|
-
"consoleErrorTest": true,
|
|
9
|
-
"renderedHtmlTest": true,
|
|
10
|
-
"pageLoadTimeTest": true,
|
|
11
|
-
"externalScriptTest": true,
|
|
12
|
-
"brokenLinkTest": true
|
|
13
|
-
},
|
|
14
|
-
"urls": [
|
|
15
|
-
{
|
|
16
|
-
"url": "../../test-cases/horizontalScrollbar.html",
|
|
17
|
-
"settings": {
|
|
18
|
-
"horizontalScrollbarTest": false
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"url": "../../test-cases/htmlError.html",
|
|
23
|
-
"settings": {
|
|
24
|
-
"renderedHtmlTest": false
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|