【发布时间】:2019-09-07 10:27:40
【问题描述】:
我需要以编程方式检查谷歌灯塔审计的结果。 F.e.来自 MSTest(如单元或完整性测试)。
如何从 c# 代码分析我的网站?
【问题讨论】:
标签: c# .net asp.net-core audit lighthouse
我需要以编程方式检查谷歌灯塔审计的结果。 F.e.来自 MSTest(如单元或完整性测试)。
如何从 c# 代码分析我的网站?
【问题讨论】:
标签: c# .net asp.net-core audit lighthouse
您可以使用lighthouse.net 库。
请注意,它需要在您的机器上安装 Node Js。
[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);
}
}
【讨论】: