structured-data-testing-tool
structured-data-testing-tool copied to clipboard
Add `url` property to tests
Summary of proposed feature
Add url
property to tests and presets that can be used to link to documentation, and display the the URL in the CLI when a test does not pass (ie on error or warning).
Purpose of proposed feature Provide a way to reference online documentation to resolve issues, especially when a test fails.
Detail of the proposed feature
- If defined on a preset, the
url
property for a preset should be displayed in the console under the preset name. - If defined on a test, the
url
property should be displayed under the name of the property if the test does not pass (ie on error or warning).
This property should link to pages that document a schema and/or can help resolve the specific problem. It would work well with the new schema.org property tests (which are in master but not in the release version).
Potential problems None.
Describe any alternatives you've considered None.
Additional context URL properties for Schema objects could also be automatically generated.
This feature has been added but not yet documented, this issue should remain open until it is.
URLs can be specified on both presets and tests, like this:
const Twitter = {
name: 'Twitter',
description: 'Suggested metatags for Twitter',
url: 'https://developer.twitter.com/en/docs/tweets/optimize-with-cards',
tests: [
{ test: `"twitter:card"`, type: 'metatag', description: 'must have card type' },
{ test: `"twitter:title"`, type: 'metatag', description: 'must have title' },
{ test: `"twitter:description"`, type: 'metatag', description: 'must have description' },
{ test: `"twitter:image" || "twitter:image:src"`, type: 'metatag', description: 'must have image url' },
{ test: `"twitter:image:alt"`, type: 'metatag', description: 'must have image alt text' },
{ test: `"twitter:site"`, type: 'metatag', warning: true, description: 'should have account username' },
{ test: `"twitter:creator"`, type: 'metatag', warning: true, description: 'should have username of content creator' },
],
}
It is currently only really used internally by the CLI (although 'url' objects are exposed via the API too) but is worth documenting - especially if/when the CLI is able to use custom presets.
NB: If a test (or preset that is part of another preset) does not have a URL, but a parent preset does, then they will inherit the URL property from the nearest parent preset, this is so that you can specify a URL once for multiple tests, while still being able to link to more specific documentation for any given test.