Skip to content

Auditing, performance metrics, and best practices for Progressive Web Apps in .NET tests.

License

Notifications You must be signed in to change notification settings

dima-hx/lighthouse.net

Repository files navigation

lighthouse.net Nuget

This is a .net (c#) library for Google Lighthouse tool.

Lighthouse.NET analyzes web apps and web pages, collecting modern performance metrics and insights on developer best practices from your code.

Auditing, performance metrics, and best practices for Progressive Web Apps in .NET tests.

How to install

You need to install lighthouse as Node module on machine (more info).

  1. Download Google Chrome for Desktop.

  2. Install the current Long-Term Support version of Node.

  3. Install Lighthouse. The -g flag installs it as a global module. npm install -g lighthouse

  4. Install lighthouse.net into your project via NuGet

PM> Install-Package lighthouse.net

Basic example

[TestClass]
public class LighthouseTest
{
    [TestMethod]
    public async Task ExampleComAudit()
    {
        var lh = new Lighthouse();
        var res = await lh.Run("http://example.com");
        Assert.IsNotNull(res);
        Assert.IsNotNull(res.Performance);
        Assert.IsTrue(res.Performance > 0.5m);

        Assert.IsNotNull(res.Accessibility);
        Assert.IsTrue(res.Accessibility > 0.5m);

        Assert.IsNotNull(res.BestPractices);
        Assert.IsTrue(res.BestPractices > 0.5m);

        Assert.IsNotNull(res.Pwa);
        Assert.IsTrue(res.Pwa > 0.5m);

        Assert.IsNotNull(res.Seo);
        Assert.IsTrue(res.Seo > 0.5m);
    }
}

Known Issues

  • If you installed lighthouse package with version 9.0.0 and higher it's required to use Node.js version 14 (because Optional Chaining Operator is used in lighthouse package). To install lighthouse package, that supports Node.js v12 please use npm i lighthouse@8.6.0 -g

Releases

No releases published

Packages

No packages published

Languages