-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add support for external reporters * reporters tests * add reporters documentation * fix reporters merging from CLI * reporters: built-in report map object and results method refactor * Update lib/helpers/resolver.js Co-authored-by: Joey Ciechanowicz <[email protected]> * documentation fix * refactor fallback values * Update lib/helpers/reporter.js Co-authored-by: Aaron Goldenthal <[email protected]> * Update lib/pa11y-ci.js Co-authored-by: Aaron Goldenthal <[email protected]> * move logs to a dedicated reporter * deduplicate and refactor reporters loader * review repoters methods * update reporters docs * typo * Add JSON reporter and unit tests * Move test data to mock folder * Update reporters to accept CLI/JSON reporter shorthand name * add multiple reporters tests * json reporter: resolve relative paths and ensure parent folders exist * reporters integratino test * docs: json reporter filename resolve strategy * rename reporters tests folder * Update README.md Co-authored-by: Aaron Goldenthal <[email protected]> * Update lib/reporters/json.js Co-authored-by: Aaron Goldenthal <[email protected]> * Fixes defaults to original values, and linting * Uses unlinkSync for v12 support Co-authored-by: Joey Ciechanowicz <[email protected]> Co-authored-by: Aaron Goldenthal <[email protected]> Co-authored-by: Aaron Goldenthal <[email protected]> Co-authored-by: Joey Ciechanowicz <[email protected]>
- Loading branch information
1 parent
40ba01a
commit 5c842cf
Showing
23 changed files
with
5,663 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
const noop = () => undefined; | ||
|
||
module.exports = { | ||
concurrency: 1, | ||
log: { | ||
error: noop, | ||
info: noop | ||
}, | ||
wrapWidth: 80, | ||
reporters: ['cli'], | ||
useIncognitoBrowserContext: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
module.exports = function loadReporter(reporter) { | ||
try { | ||
return require(reporter); | ||
} catch (_) { | ||
const localModule = path.resolve(process.cwd(), reporter); | ||
if (!fs.existsSync(localModule)) { | ||
console.error(`Unable to load reporter "${reporter}"`); | ||
return undefined; | ||
} | ||
return require(localModule); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
const loadReporter = require('./loader'); | ||
|
||
const reporterShorthand = { | ||
cli: require.resolve('../reporters/cli.js'), | ||
json: require.resolve('../reporters/json.js') | ||
}; | ||
|
||
module.exports = function resolveReporters(config = {}) { | ||
if (!Array.isArray(config.reporters) || config.reporters.length === 0) { | ||
return []; | ||
} | ||
return config.reporters.map(reporter => { | ||
let reporterOptions = {}; | ||
if (Array.isArray(reporter)) { | ||
[reporter, reporterOptions = {}] = reporter; | ||
} | ||
if (typeof reporter !== 'string') { | ||
return undefined; | ||
} | ||
if (Object.keys(reporterShorthand).includes(reporter)) { | ||
reporter = reporterShorthand[reporter]; | ||
} | ||
const reporterModule = loadReporter(reporter); | ||
|
||
if (typeof reporterModule === 'function') { | ||
return reporterModule(reporterOptions, config); | ||
} | ||
return reporterModule; | ||
}).filter(Boolean); | ||
}; |
Oops, something went wrong.