DotnetLighthouse 1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DotnetLighthouse --version 1.0.2
NuGet\Install-Package DotnetLighthouse -Version 1.0.2
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.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotnetLighthouse --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DotnetLighthouse, 1.0.2"
#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.2 // Install DotnetLighthouse as a Cake Tool #tool nuget:?package=DotnetLighthouse&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DotnetLighthouse
DotnetLighthouse is a .NET library to run Lighthouse audits and process the results.
Prerequisites
- Make sure you have latest version of Node install (recommend to use LTS version) https://nodejs.org/en/download/prebuilt-installer
- Install Lighthouse cli globally, by running following command by opening up your terminal/command prompt
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 | Versions 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.
-
net8.0
- HtmlAgilityPack (>= 1.11.67)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.