DotnetLighthouse 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotnetLighthouse --version 1.0.1                
NuGet\Install-Package DotnetLighthouse -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotnetLighthouse" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotnetLighthouse --version 1.0.1                
#r "nuget: DotnetLighthouse, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DotnetLighthouse as a Cake Addin
#addin nuget:?package=DotnetLighthouse&version=1.0.1

// Install DotnetLighthouse as a Cake Tool
#tool nuget:?package=DotnetLighthouse&version=1.0.1                

DotnetLighthouse

DotnetLighthouse is a .NET library to run Lighthouse audits and process the results.

Prerequisites

npm install -g lighthouse 
  • You already have your dotnet test project using .net8.0 or higher or use following to create a xunit project
dotnet new xunit -o DotnetLighthouse.Tests

Installation

Now navigate to your project directory (e.g. DotnetLighthouse.Tests) You can install the DotnetLighthouse package by running following command in terminal:

dotnet add package DotnetLighthouse

Sample Code

  • Create a new test file "LighthouseAudit.cs"
  • Add following code into the class
using System;
using Xunit;
using DotnetLighthouse;

public class LighthouseAudit
{
[Fact]
        public void ValidateJsonAudit()
        {
            // Define the URL to be audited
            var url = "https://www.google.com";
            
            // Create an instance of LighthouseHelper with the specified URL
            var lighthouseHelper = new LighthouseHelper(url);
            
            // Run the Lighthouse audit for the specified URL
            lighthouseHelper.RunLighthouseAudit();
            
            // Retrieve the performance score from the Lighthouse audit results
            var performanceScore = lighthouseHelper.PerformanceScore;
            
            // Retrieve the accessibility score from the Lighthouse audit results
            var accessibilityScore = lighthouseHelper.AccessibilityScore;
            
            // Retrieve the best practices score from the Lighthouse audit results
            var bestPracticesScore = lighthouseHelper.BestPracticesScore;
            
            // Retrieve the SEO score from the Lighthouse audit results
            var seoScore = lighthouseHelper.SeoScore;
            
            // Retrieve the PWA score from the Lighthouse audit results
            var pwaScore = lighthouseHelper.PwaScore;
            
            // Assert that the performance score is greater than 90
            Assert.True(performanceScore > 90);
        }
}

More Configurations

  • By Default DotnetLighthouse generate Lghthouse Audit report with name "lighthouse-report.json" in bin folder. In case you want a different name you can update by overriding property "OutputPath"

Dependencies

This project has the following dependencies:

  • HtmlAgilityPack
  • Newtonsoft.Json

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Authors

Raj Uppadhyay

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 112 10/15/2024
1.0.4 89 10/14/2024
1.0.3 95 10/13/2024
1.0.2 83 10/13/2024
1.0.1 86 10/13/2024
1.0.0 83 10/13/2024