-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
seo-failing.js
101 lines (94 loc) · 1.96 KB
/
seo-failing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
const BASE_URL = 'http://localhost:10200/seo/';
/** @type {LH.Config} */
const config = {
extends: 'lighthouse:default',
settings: {
onlyCategories: ['seo'],
},
};
/**
* @param {[string, string][]} headers
* @return {string}
*/
function headersParam(headers) {
const headerString = new URLSearchParams(headers).toString();
return new URLSearchParams([['extra_header', headerString]]).toString();
}
const failureHeaders = headersParam([[
'x-robots-tag',
'none',
], [
'link',
'<http://example.com>;rel="alternate";hreflang="xx"',
], [
'link',
'<https://example.com>; rel="canonical"',
]]);
/**
* @type {Smokehouse.ExpectedRunnerResult}
* Expected Lighthouse audit values for a site that fails seo tests.
*/
const expectations = {
lhr: {
requestedUrl: BASE_URL + 'seo-failure-cases.html?' + failureHeaders,
finalDisplayedUrl: BASE_URL + 'seo-failure-cases.html?' + failureHeaders,
audits: {
'document-title': {
score: 0,
},
'meta-description': {
score: 0,
},
'http-status-code': {
score: 1,
},
'crawlable-anchors': {
score: 0,
details: {
items: {
length: 4,
},
},
},
'link-text': {
score: 0,
displayValue: '4 links found',
details: {
items: {
length: 4,
},
},
},
'is-crawlable': {
score: 0,
details: {
items: {
length: 2,
},
},
},
'hreflang': {
score: 0,
details: {
items: {
length: 5,
},
},
},
'canonical': {
score: 0,
explanation: 'Multiple conflicting URLs (https://example.com/other, https://example.com/)',
},
},
},
};
export default {
id: 'seo-failing',
expectations,
config,
};