playwright-lighthouse icon indicating copy to clipboard operation
playwright-lighthouse copied to clipboard

Possible test framework-agnostic enhancements

Open tabermike opened this issue 5 years ago • 3 comments

It would be nice to keep this package/library test framework-agnostic, yet expand capabilities to allow for deeper tests. Along these lines I have been thinking that the ability to pull out individual results could be quite useful. Flow might be something like this:

// in setup portion of a test
// maybe just specify categories, without thresholds, since in this case they would not be used
const lhr = await getLighthouseReport({
      page: page,
      thresholds: {
        performance: 50,
        accessibility: 50,
        'best-practices': 50,
        seo: 50,
        pwa: 50,
      },
      port: 9222,
    });

// in examples we might:
const perfScore = await getCategoryScore('performance');

// example of a simple, Chai, expect
expect(perfScore).to.be.at.least(50);

Rather rough concept right now, but the idea is: run an Audit and allow user/tester to assert/expect/validate only the portions of concern. It might be as broad as Categories (as in the example flow above). Or perhaps the concern (for a given test) is: Performance --> first-contentful-paint and interactive

Could go coarse-grained or fine-grained.

tabermike avatar Jul 02 '20 14:07 tabermike

@tabermike you may run playAudit with ignoreError set to true and then do any assertions you like. Ex

const results = await playAudit({ url, port, ignoreError: true })
expect(results.lhr.categories['performance'].score * 100).toBeGreaterThan(50)

grybykm avatar Mar 28 '22 14:03 grybykm

@grybykm we can think about factory methods to get easy access on the metrics.

abhinaba-ghosh avatar Mar 28 '22 17:03 abhinaba-ghosh

Помогите мне найти где-нибудь примеры кода нормальных тестов с playwright-lighthouse где есть авторизация и т.д. Ещё мне нужно узнать есть ли тут интеграции с Docker, чтобы запускать его в докер-контейнерах.

Arseniy184 avatar Jul 05 '22 21:07 Arseniy184