Skip to content

Commit 3655269

Browse files
A few requested updates and Report Tweaks.
Updates Include: --- - [X] Adds new `viewport` config option that lets you set the screen size of the browser - [X] Adds new `runInBrowser` config option that will open the tests in a new Chrome window so you can see the tests being run - [X] Adds check for Actions that use `screen capture filename.jpg` that do not set absolute path and corrects path to output folder - [X] Updates Documentation for new Config Options - [X] Updates Screenshot Styling on HTML Report by aligning image to top
1 parent 7c59fdd commit 3655269

File tree

7 files changed

+94
-7
lines changed

7 files changed

+94
-7
lines changed

bin/cli.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ const argv = yargs
8383
describe: 'Include Warnings in Report',
8484
type: 'boolean',
8585
default: true
86+
},
87+
runInBrowser: {
88+
alias: 'b',
89+
describe: 'Run Tests in Browser Window',
90+
type: 'boolean',
91+
default: false
92+
},
93+
viewport: {
94+
alias: 'V',
95+
describe: 'Viewport Screen Size',
96+
type: 'string',
97+
default: 'desktop'
8698
}
8799
})
88100
.command('*', 'Run A11Y Tests using Options')

commands/a11y.js

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,19 @@ module.exports = async options => {
113113
opts.ignore = test.ignore
114114
}
115115

116+
// Set actions if they are there, and do a quick check for common issues
116117
if (test.actions && Array.isArray(test.actions)) {
118+
test.actions.forEach((action, index) => {
119+
if (action.startsWith('screen capture ')) {
120+
const parts = action.split(' ')
121+
122+
// Check if the file name has a path, if not, we need to set it
123+
if (parts.length === 3 && parts[2].indexOf('/') === -1 && parts[2].indexOf('\\') === -1) {
124+
test.actions[index] = `screen capture ${path.join(opts.output, parts[2])}`
125+
}
126+
}
127+
})
128+
117129
opts.actions = test.actions
118130
}
119131

@@ -158,6 +170,47 @@ module.exports = async options => {
158170
}
159171
}
160172

173+
// Run in Browser
174+
if (opts.runInBrowser) {
175+
// Add Chrome Settings
176+
opts.chromeLaunchConfig = {
177+
headless: false
178+
}
179+
}
180+
181+
// Set Screenshot Viewport Size
182+
if (opts.viewport && ['desktop', 'tablet', 'tablet-landscape', 'tablet-portrait', 'mobile'].indexOf(opts.viewport) !== -1) {
183+
const sizes = {
184+
'desktop': {
185+
width: 1366,
186+
height: 768,
187+
isMobile: false
188+
},
189+
'tablet': {
190+
width: 1024,
191+
height: 768,
192+
isMobile: true
193+
},
194+
'tablet-landscape': {
195+
width: 1024,
196+
height: 768,
197+
isMobile: true
198+
},
199+
'tablet-portrait': {
200+
width: 768,
201+
height: 1024,
202+
isMobile: true
203+
},
204+
'mobile': {
205+
width: 360,
206+
height: 640,
207+
isMobile: true
208+
}
209+
}
210+
211+
opts.viewport = sizes[opts.viewport]
212+
}
213+
161214
if (opts.screenCapture) {
162215
const timestamp = moment().format('YYYYMMDD_HHmmssSSSS')
163216
opts.screenCapture = path.join(opts.output, `screenshot_${website.host}_${timestamp}.jpg`)
@@ -193,7 +246,8 @@ module.exports = async options => {
193246
logger(() => { console.log(status.message) })
194247
spinner.succeed(`${chalk.green.bold('Testing Complete')}\n`)
195248

196-
if (options.open) {
249+
// Open report if requested, unless compressing ( not required )
250+
if (options.open && !options.compress) {
197251
open(status.file)
198252
}
199253
} else if (testResults.settings.format === 'cli') {

docs/cmd-a11y.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ Options:
1616
Name | JSON Param | CLI Param & Alias | Default | Definition
1717
---------------|-----------------|--------------------------|-----------|----------------------------------------------
1818
Actions | `actions` | `--actions`, `-a` | `[]` | Test Actions ( [Learn More](actions.md) )
19+
Compress | `compress` | `--compress`, `-C` | `false` | Compress Report ( Only works on HTML Format )
1920
Config | | `--config`, `-c` | | Absolute Path to Configuration File
2021
Format | `format` | `--format`, `-f` | `cli` | Output Format of Report [ `cli`, `csv`, `html`, `jira`, `json`, `md`, `xml` ]
21-
Compress | `compress` | `--compress`, `-C` | `false` | Compress Report ( Only works on HTML Format )
2222
Ignore | `ignore` | `--ignore`, `-i` | `[]` | Error Codes to Ignore ( `WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail` )
2323
Notices | `notices` | `--notices`, `-n` | `true` | Include Notices in Report ( `--notices=false` or `--no-notices` to disable )
24-
Open | `open` | `--open`, `-O` | `false` | Open Report after Creation
24+
Open | `open` | `--open`, `-O` | `false` | Open Report after Creation ( disabled if using `--compress` )
2525
Output | `output` | `--output`, `-o` | | Absolute Path to Output Directory for Report ( `cwd` if not provided )
26+
Run in Browser | `runInBrowser` | `--run-in-browser`, `-b` | `false` | Run Tests in Browser ( helpful for tests that require sessions / authentication )
2627
Screen Capture | `screenCapture` | `--screen-capture`, `-S` | `false` | Whether to add a Screen Capture for Report
2728
Standard | `standard` | `--standard`, `-s` | `WCAG2AA` | Accessibility Standard [ `Section508`, `WCAG2A`, `WCAG2AA`, `WCAG2AAA` ]
2829
Timeout | `timeout` | `--timeout`, `-t` | `30000` | Test Timeout in Milliseconds
30+
Viewport | `viewport` | `--viewport`, `-V` | `desktop` | Viewport Screen Size [ `desktop`, `tablet-landscape`, `tablet-portrait`, `mobile` ]
2931
Wait | `wait` | `--wait`, `-W` | `0` | Page Load Wait in Milliseconds
3032
Warnings | `warnings` | `--warnings`, `-w` | `true` | Include Warnings in Report ( `--warnings=false` or `--no-warnings` to disable )
3133

@@ -152,4 +154,15 @@ It's possible to overload settings in your `config` file by passing in CLI param
152154
```bash
153155
rvw-a11y --config=/path/to/config.json --output=/path/to/other/folder
154156
rvw-a11y -c /path/to/config.json -o /path/to/other/folder
155-
```
157+
```
158+
159+
160+
Viewport Screen Sizes:
161+
---
162+
163+
Size | Width | Height
164+
-------------------|-------|---------
165+
`desktop` | 1366 | 768
166+
`tablet-landscape` | 1024 | 768
167+
`tablet-portrait` | 768 | 1024
168+
`mobile` | 360 | 640

lib/config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ module.exports = async options => {
102102
config.includeWarnings = options.warnings
103103
}
104104

105+
if (typeof options.runInBrowser === 'boolean') {
106+
config.runInBrowser = options.runInBrowser
107+
}
108+
109+
if (options.viewport && ['desktop', 'tablet', 'tablet-landscape', 'tablet-portrait', 'mobile'].indexOf(options.viewport) !== -1) {
110+
config.viewport = options.viewport
111+
}
112+
105113
// Map any arguments passed via CLI that were not flags and check if they are URL's to test
106114
if (options['_'] && options['_'].length > 0) {
107115
// Initialize Tests if not already present

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rvw-accessibility-tester",
3-
"version": "1.2.1",
3+
"version": "1.3.0",
44
"description": "Automated Accessibility Tester for Client Websites",
55
"homepage": "https://github.com/redvanworkshop/accessibility-tester#readme",
66
"license": "MIT",

resources/report.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
display: block;
329329
width: 200px;
330330
height: 125px;
331-
background: center center no-repeat;
331+
background: top center no-repeat;
332332
background-size: cover;
333333
box-shadow: 0 0 4px rgba(0,0,0,0.25);
334334
}

0 commit comments

Comments
 (0)