Skip to content

Commit 3e7ff89

Browse files
committed
Replace 'info' option with 'optional' option
* The 'info' option was rarely used and is no longer supported. * The 'info' has been replaced by the similar 'optional' option. * Optional tests do not count towards passed, failed or total tests run. * Optional tests can be inspected via the API and Command Line Interface. * Optional tests are shown differently to other tests in the CLI output. * Includes new tests in the Google preset that use this option.
1 parent e62c747 commit 3e7ff89

File tree

12 files changed

+461
-341
lines changed

12 files changed

+461
-341
lines changed

README.md

+71-26
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,58 @@ SocialMedia Suggested markup for integration with social media sit
9292
$ sdtt --url https://www.bbc.co.uk/news/world-us-canada-49060410 --presets Google,SocialMedia
9393
Tests
9494
95-
Schema.org > ReportageNewsArticle - 100% (1 passed, 1 total)
95+
Schema.org > ReportageNewsArticle - 100% (1 passed, 0 failed)
9696
✓ schema in jsonld
97-
98-
Google > ReportageNewsArticle - 100% (12 passed, 12 total)
97+
• @context
98+
• @type
99+
• url
100+
• publisher.@type
101+
• publisher.name
102+
• publisher.publishingPrinciples
103+
• publisher.logo.@type
104+
• publisher.logo.url
105+
• datePublished
106+
• dateModified
107+
• headline
108+
• image.@type
109+
• image.width
110+
• image.height
111+
• image.url
112+
• thumbnailUrl
113+
• author.@type
114+
• author.name
115+
• author.logo.@type
116+
• author.logo.url
117+
• author.noBylinesPolicy
118+
• mainEntityOfPage
119+
• video.@list[0].@type
120+
• video.@list[0].name
121+
• video.@list[0].description
122+
• video.@list[0].duration
123+
• video.@list[0].thumbnailUrl
124+
• video.@list[0].uploadDate
125+
• video.@list[1].@type
126+
• video.@list[1].name
127+
• video.@list[1].description
128+
• video.@list[1].duration
129+
• video.@list[1].thumbnailUrl
130+
• video.@list[1].uploadDate
131+
132+
Google > ReportageNewsArticle > #0 (jsonld) - 100% (12 passed, 0 failed)
99133
✓ ReportageNewsArticle
100-
ReportageNewsArticle[*]."@type"
101-
ReportageNewsArticle[*].author
102-
ReportageNewsArticle[*].datePublished
103-
ReportageNewsArticle[*].headline
104-
ReportageNewsArticle[*].image
105-
ReportageNewsArticle[*].publisher."@type"
106-
ReportageNewsArticle[*].publisher.name
107-
ReportageNewsArticle[*].publisher.logo
108-
ReportageNewsArticle[*].publisher.logo.url
109-
ReportageNewsArticle[*].dateModified
110-
ReportageNewsArticle[*].mainEntityOfPage
111-
112-
SocialMedia > Facebook - 100% (8 passed, 8 total)
134+
✓ @type
135+
✓ author
136+
✓ datePublished
137+
✓ headline
138+
✓ image
139+
✓ publisher.@type
140+
✓ publisher.name
141+
✓ publisher.logo
142+
✓ publisher.logo.url
143+
✓ dateModified
144+
✓ mainEntityOfPage
145+
146+
Facebook - 100% (8 passed, 0 failed)
113147
✓ must have page title
114148
✓ must have page type
115149
✓ must have url
@@ -119,7 +153,7 @@ Tests
119153
✓ should have account username
120154
✓ should have locale
121155
122-
SocialMedia > Twitter - 100% (7 passed, 7 total)
156+
Twitter - 100% (7 passed, 0 failed)
123157
✓ must have card type
124158
✓ must have title
125159
✓ must have description
@@ -136,16 +170,19 @@ Statistics
136170
Schema in RDFa: 0
137171
Schema.org schemas: ReportageNewsArticle
138172
Other schemas: 0
139-
Test groups run: 4
140-
Total tests run: 28
173+
Test groups run: 5
174+
Optional tests run: 71
175+
Pass/Fail tests run: 28
141176
142177
Results
143178
144-
Passed: 28 (100%)
145-
Warnings: 0 (0%)
146-
Failed: 0 (0%)
179+
Passed: 28 (100%)
180+
Warnings: 0 (0%)
181+
Failed: 0 (0%)
147182
148183
✓ 28 tests passed with 0 warnings.
184+
185+
Use the option '-i' to display additional detail.
149186
```
150187

151188
### API
@@ -404,16 +441,22 @@ When `warning` is set to `true`, if the test does not pass it will only result i
404441

405442
The default is `false`, meaning if the test fails it will be counted as a failure.
406443

407-
#### info
444+
#### optional
408445
```
409446
Type: boolean
410447
Required: false
411448
Default: false
412449
```
413450

414-
When `info` is set to `true`, if the test passes it will not register as pass, but you can use `--info/-i` on the CLI or inspect the `info` property on the response from the API to see it.
451+
When the `optional` property is set to `true` on a test, a test will not count as either passed or failed, but the test will still be run and the result able to be inspected.
452+
453+
Optional tests do not count towards the total number of tests run, test passed or tests failed. They will show up in results in the Command Line Interface if they pass, but not if they fail; however passing optional tests appear differently to other tests in the results to make it clear they are optional checks.
415454

416-
The default is `false`. This option can be used in conjunction with `warning` if it should not be counted as a failed test if it does not pass.
455+
You can use `--info/-i` on the CLI or inspect the `optional` property on the response from the API to see the result of any test that has `optional` property set on it. However, if an optional test fails because the property it was testing does not exist, it will not be displayed in the CLI. If a property is optional but recommended, use the `warning` option instead.
456+
457+
Note: Strictly speaking, in principle no specific properties on Schema.org objects are "required" but in practice implementations by vendors like Google have some "required" or expected properties and also respect some "optional" properties; this option is useful for writing tests that don't fail if a valid, but not necessarily required, property is not found.
458+
459+
The default is `false`.
417460

418461
#### conditional
419462
```
@@ -424,10 +467,12 @@ Default: undefined
424467

425468
A `conditional` object can contain a conditional test to be run, to determine if the test itself should be run.
426469

427-
If the conditional test fails, the test will not be run (and it will not be included in the test results). If the conditional test passes, the test will be run and the pass / fail / info / warning included in the results.
470+
If the conditional test fails, the test will not be run (and it will not be included in the test results). If the conditional test passes, the test will be run as it otherwise would be if the condition wasn't specified.
428471

429472
This is considered advanced usage, to help avoid having to write overly complex test statements. Conditional test objects use the same syntax as regular test objects, but conditional tests are not included in the results.
430473

474+
It is particularly useful for checking if it is appropriate to run a group of tests. For example, it is used by internal presets to check if a schema exists; if it does then all the tests for that schema are run (and required tests must pass), but if a schema does not exist then none of the tests for that schema are run.
475+
431476
#### group
432477
```
433478
Type: string

0 commit comments

Comments
 (0)