Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "The property _____ was not found" is received if expect value different from actual #20

Open
Paychokxxx opened this issue Apr 9, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@Paychokxxx
Copy link

Paychokxxx commented Apr 9, 2020

Describe the bug
Incorrect error is displayed

To Reproduce
After run of

const { structuredDataTest } = require('structured-data-testing-tool')
const url = 'https://www.bbc.co.uk/news/world-us-canada-49060410'
const testUrl = 'https://www.bbc.co.uk/news/world-us-canada-49060410_EXTRA_TEXT'

const CustomPreset = {
    name: 'Non-premium About Page',
    description: 'Test all the structured data is correct for Non-premium about tab',
    tests: [
        // Check 'NewsArticle' schema exists in JSON-LD
        { test: 'ReportageNewsArticle', expect: true, type: 'jsonld' },

        // Check a 'NewsArticle' schema exists with 'url' property set to the value of the  variable 'url'
        { test: 'ReportageNewsArticle[*].url', expect: testUrl },

        // A similar check as above, but won't fail (only warn) if the test doesn't pass
        { test: 'ReportageNewsArticle[*].mainEntityOfPage', expect: testUrl, warning: true },

        // Test for a Twitter meta tag with specific value
        { test: '"twitter:domain"', expect: 'www.bbc.co.uk', type: 'metatag' }
      ]
};

let result

structuredDataTest(url, {
  // Check for compliance with Google, Twitter and Facebook recommendations
  presets: [ CustomPreset ],
  // Check the page includes a specific Schema (see https://schema.org/docs/full.html for a list)
})
.then(res => {
  console.log('✅ All tests passed!')
  result = res
})
.catch(err => {
  if (err.type === 'VALIDATION_FAILED') {
    console.log('❌ Some tests failed.')
    result = err.res
  } else {
    console.log(err) // Handle other errors here (e.g. an error fetching a URL)
  }
})
.finally(() => {
  if (result) {
    console.log(
      `Passed: ${result.passed.length},`,
      `Failed: ${result.failed.length},`,
      `Warnings: ${result.warnings.length}`,
    )
    console.log(`Schemas found: ${result.schemas.join(',')}`)

    // Loop over validation errors
    if (result.failed.length > 0)
      console.log("⚠️  Errors:\n", result.failed.map(test => test))
  }
})

I receive

❌ Some tests failed.
Passed: 3, Failed: 1, Warnings: 1
Schemas found: ReportageNewsArticle
⚠️  Errors:
 [ { test: 'ReportageNewsArticle[*].url',
    expect:
     'https://www.bbc.co.uk/news/world-us-canada-49060410_EXTRA_TEXT',
    group: 'Non-premium About Page',
    passed: false,
    type: 'any',
    value: null,
    error:
     { type: 'NOT_FOUND',
       message: 'The property "ReportageNewsArticle[*].url" was not found' } } ]

Include either CLI command or example code which can be used to reproduce the behavior.

Expected behavior
Should it be ?
type: 'INCORRECT_VALUE',
message: Incorrect value found for "${path}",

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@Paychokxxx Paychokxxx added the bug Something isn't working label Apr 9, 2020
@iaincollins
Copy link
Owner

Thanks for the bug report.

If I'm reading it correctly, yes it should be INCORRECT_VALUE instead of NOT_FOUND.

I'll clean up the formatting of the ticket and take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants