question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Questions on Assert Behaviour

See original GitHub issue

The assert configuration is as below

"assert": {
  "preset": "lighthouse:no-pwa",
  "assertions": {      
      "categories:performance": ["warn", {"aggregationMethod": "optimistic", "minScore": 0.70}],
       "categories:accessibility": ["warn", {"aggregationMethod": "optimistic", "minScore": 0.90}]
    }
}

and from the Assertion Levels docs

If an audit is not found in the assertions object, it is assumed to be off. The audit result will not be checked.

Yet, when I run lhci assert I get the below output.

 ×  unused-css-rules failure for maxLength assertion
     Remove unused CSS
     Documentation: https://web.dev/unused-css-rules
        expected: <=0
           found: 1
      all values: 1, 1, 1

  ×  uses-optimized-images failure for maxLength assertion
     Efficiently encode images
     Documentation: https://web.dev/uses-optimized-images
        expected: <=0
           found: 1
      all values: 1, 1, 1

  ×  uses-responsive-images failure for maxLength assertion
     Properly size images
     Documentation: https://web.dev/uses-responsive-images
        expected: <=0
           found: 1
      all values: 1, 1, 1

  ⚠️  render-blocking-resources warning for maxLength assertion
     Eliminate render-blocking resources
     Documentation: https://web.dev/render-blocking-resources
        expected: <=0
           found: 2
      all values: 2, 2, 2

  ⚠️  uses-long-cache-ttl warning for maxLength assertion
     Serve static assets with an efficient cache policy
     Documentation: https://web.dev/uses-long-cache-ttl
        expected: <=0
           found: 7
      all values: 7, 7, 7

  ⚠️  uses-webp-images warning for maxLength assertion
     Serve images in next-gen formats
     Documentation: https://web.dev/uses-webp-images
        expected: <=0
           found: 1
      all values: 1, 1, 1

Assertion failed. Exiting with status code 1.

What I expected to happen ? That these rules are not checked because they are not in the assertion object and more importantly that the assertion result does not fail because of this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

4reactions
patrickhulcecommented, Dec 20, 2019

Thanks for filing @GuruCharan94! It’s failing because you’re using the preset lighthouse:no-pwa which has assertions on all of the non-pwa audits. If you don’t want to extend a preset and just have your assertions run, eliminate the preset property from your config.

0reactions
patrickhulcecommented, Apr 23, 2020

That’s what was done. Still get the error and builds fail.

But you just told me your configuration was

{
  "ci": {
    "assert": {
      "matchingUrlPattern": "https://[^/]",
      "preset": "lighthouse:recommended"    
    }
  }
}

so you’re using a preset and it wasn’t done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Assertions, Questions, Answers & the Common Ground
If settling answers to polar questions count as assertions, what do they assert? Presumably, a to...
Read more >
Programming With Assertions - Oracle Help Center
An assertion is a statement in the Java programming language that enables you to test your assumptions about your program. For example, if...
Read more >
Python's assert: Debug and Test Your Code Like a Pro
In this tutorial, you'll learn how to use Python's assert statement to document, debug, and test code in development.
Read more >
Assert behaviour in java? - Stack Overflow
The docs are clear: Expression2 is an expression that has a value. (It cannot be an invocation of a method that is declared...
Read more >
Assert and Verify Methods in Selenium | BrowserStack
Assertions (also known as Asserts) ... The word Assert means to state a fact or belief confidently or forcefully. In Selenium, Asserts are ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found