Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: run code coverage in github actions #11770

Merged
merged 27 commits into from
Jan 13, 2021
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
c8comments
connorjclark committed Dec 10, 2020
commit d5da5958ef6d293b85f93d294f038f357993cff1
3 changes: 2 additions & 1 deletion lighthouse-core/gather/fetcher.js
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ class Fetcher {
/**
* @param {string} src
*/
/* istanbul ignore next */
/* c8 ignore start */
function injectIframe(src) {
/** @type {HTMLIFrameElement} */
const iframe = document.createElement('iframe');
@@ -161,6 +161,7 @@ class Fetcher {
};
document.body.appendChild(iframe);
}
/* c8 ignore stop */

/** @type {NodeJS.Timeout} */
let timeoutHandle;
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/accessibility.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ const pageFunctions = require('../../lib/page-functions.js');
* containing any violations.
* @return {Promise<LH.Artifacts.Accessibility>}
*/
/* istanbul ignore next */
/* c8 ignore start */
function runA11yChecks() {
// @ts-expect-error axe defined by axeLibSource
return window.axe.run(document, {
@@ -91,6 +91,7 @@ function runA11yChecks() {
return axeResults;
});
}
/* c8 ignore stop */

/**
* @implements {LH.Gatherer.FRGathererInstance}
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/anchor-elements.js
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ const pageFunctions = require('../../lib/page-functions.js');
*
* @return {LH.Artifacts['AnchorElements']}
*/
/* istanbul ignore next */
/* c8 ignore start */
function collectAnchorElements() {
/** @param {string} url */
const resolveURLOrEmpty = url => {
@@ -71,6 +71,7 @@ function collectAnchorElements() {
};
});
}
/* c8 ignore stop */

/**
* @param {LH.Gatherer.PassContext['driver']} driver
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/cache-contents.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ const Gatherer = require('./gatherer.js');
* This is run in the page, not Lighthouse itself.
* @return {Promise<Array<string>>}
*/
/* istanbul ignore next */
/* c8 ignore start */
function getCacheContents() {
// Get every cache by name.
return caches.keys()
@@ -36,6 +36,7 @@ function getCacheContents() {
});
});
}
/* c8 ignore stop */

class CacheContents extends Gatherer {
/**
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/dobetterweb/domstats.js
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ const pageFunctions = require('../../../lib/page-functions.js');
* @param {boolean=} deep True to include shadow roots. Defaults to true.
* @return {LH.Artifacts.DOMStats}
*/
/* istanbul ignore next */
/* c8 ignore start */
function getDOMStats(element, deep = true) {
let deepestElement = null;
let maxDepth = -1;
@@ -73,6 +73,7 @@ function getDOMStats(element, deep = true) {
totalBodyElements: result.numElements,
};
}
/* c8 ignore stop */

class DOMStats extends Gatherer {
/**
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ const pageFunctions = require('../../../lib/page-functions.js');
/**
* @return {LH.Artifacts['PasswordInputsWithPreventedPaste']}
*/
/* istanbul ignore next */
/* c8 ignore start */
function findPasswordInputsWithPreventedPaste() {
return Array.from(document.querySelectorAll('input[type="password"]'))
.filter(passwordInput =>
@@ -27,6 +27,7 @@ function findPasswordInputsWithPreventedPaste() {
node: getNodeDetails(passwordInput),
}));
}
/* c8 ignore stop */

class PasswordInputsWithPreventedPaste extends Gatherer {
/**
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ const Driver = require('../../driver.js'); // eslint-disable-line no-unused-vars

/* global document,window,HTMLLinkElement */

/* istanbul ignore next */
/* c8 ignore start */
function installMediaListener() {
window.___linkMediaChanges = [];
Object.defineProperty(HTMLLinkElement.prototype, 'media', {
@@ -40,11 +40,12 @@ function installMediaListener() {
},
});
}
/* c8 ignore stop */

/**
* @return {Promise<{tagName: string, url: string, src: string, href: string, rel: string, media: string, disabled: boolean, mediaChanges: {href: string, media: string, msSinceHTMLEnd: number, matches: boolean}}>}
*/
/* istanbul ignore next */
/* c8 ignore start */
function collectTagsThatBlockFirstPaint() {
return new Promise((resolve, reject) => {
try {
@@ -91,6 +92,7 @@ function collectTagsThatBlockFirstPaint() {
}
});
}
/* c8 ignore stop */

class TagsBlockingFirstPaint extends Gatherer {
/**
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/form-elements.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ const pageFunctions = require('../../lib/page-functions.js');
/**
* @return {LH.Artifacts['FormElements']}
*/
/* istanbul ignore next */
/* c8 ignore start */
function collectFormElements() {
// @ts-expect-error - put into scope via stringification
const formChildren = getElementsInDocument('textarea, input, label, select'); // eslint-disable-line no-undef
@@ -82,6 +82,7 @@ function collectFormElements() {
}
return [...forms.values()];
}
/* c8 ignore stop */

class FormElements extends Gatherer {
/**
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/html-without-javascript.js
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ const Gatherer = require('./gatherer.js');

/* global document */

/* istanbul ignore next */
/* c8 ignore start */
function getBodyText() {
// note: we use innerText, not textContent, because textContent includes the content of <script> elements!
const body = document.querySelector('body');
@@ -23,6 +23,7 @@ function getBodyText() {
hasNoScript: !!document.querySelector('noscript'),
});
}
/* c8 ignore stop */

class HTMLWithoutJavaScript extends Gatherer {
/**
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/iframe-elements.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ const pageFunctions = require('../../lib/page-functions.js');
/**
* @return {LH.Artifacts['IFrameElements']}
*/
/* istanbul ignore next */
/* c8 ignore start */
function collectIFrameElements() {
// @ts-expect-error - put into scope via stringification
const iFrameElements = getElementsInDocument('iframe'); // eslint-disable-line no-undef
@@ -33,6 +33,7 @@ function collectIFrameElements() {
};
});
}
/* c8 ignore stop */

class IFrameElements extends Gatherer {
/**
18 changes: 12 additions & 6 deletions lighthouse-core/gather/gatherers/image-elements.js
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ const FontSize = require('./seo/font-size.js');
/* global window, getElementsInDocument, Image, getNodeDetails, ShadowRoot */

/** @param {Element} element */
/* istanbul ignore next */
/* c8 ignore start */
function getClientRect(element) {
const clientRect = element.getBoundingClientRect();
return {
@@ -28,27 +28,29 @@ function getClientRect(element) {
right: clientRect.right,
};
}
/* c8 ignore stop */

/**
* If an image is within `picture`, the `picture` element's css position
* is what we want to collect, since that position is relevant to CLS.
* @param {Element} element
* @param {CSSStyleDeclaration} computedStyle
*/
/* istanbul ignore next */
/* c8 ignore start */
function getPosition(element, computedStyle) {
if (element.parentElement && element.parentElement.tagName === 'PICTURE') {
const parentStyle = window.getComputedStyle(element.parentElement);
return parentStyle.getPropertyValue('position');
}
return computedStyle.getPropertyValue('position');
}
/* c8 ignore stop */

/**
* @param {Array<Element>} allElements
* @return {Array<LH.Artifacts.ImageElement>}
*/
/* istanbul ignore next */
/* c8 ignore start */
function getHTMLImages(allElements) {
const allImageElements = /** @type {Array<HTMLImageElement>} */ (allElements.filter(element => {
return element.localName === 'img';
@@ -84,12 +86,13 @@ function getHTMLImages(allElements) {
};
});
}
/* c8 ignore stop */

/**
* @param {Array<Element>} allElements
* @return {Array<LH.Artifacts.ImageElement>}
*/
/* istanbul ignore next */
/* c8 ignore start */
function getCSSImages(allElements) {
// Chrome normalizes background image style from getComputedStyle to be an absolute URL in quotes.
// Only match basic background-image: url("http://host/image.jpeg") declarations
@@ -130,21 +133,23 @@ function getCSSImages(allElements) {

return images;
}
/* c8 ignore stop */

/** @return {Array<LH.Artifacts.ImageElement>} */
/* istanbul ignore next */
/* c8 ignore start */
function collectImageElementInfo() {
/** @type {Array<Element>} */
// @ts-expect-error - added by getElementsInDocumentFnString
const allElements = getElementsInDocument();
return getHTMLImages(allElements).concat(getCSSImages(allElements));
}
/* c8 ignore stop */

/**
* @param {string} url
* @return {Promise<{naturalWidth: number, naturalHeight: number}>}
*/
/* istanbul ignore next */
/* c8 ignore start */
function determineNaturalSize(url) {
return new Promise((resolve, reject) => {
const img = new Image();
@@ -159,6 +164,7 @@ function determineNaturalSize(url) {
img.src = url;
});
}
/* c8 ignore stop */

/**
* @param {Partial<Pick<LH.Crdp.CSS.CSSStyle, 'cssProperties'>>|undefined} rule
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/link-elements.js
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ function getCrossoriginFromHeader(value) {
/**
* @return {LH.Artifacts['LinkElements']}
*/
/* istanbul ignore next */
/* c8 ignore start */
function getLinkElementsInDOM() {
/** @type {Array<HTMLOrSVGElement>} */
// @ts-expect-error - getElementsInDocument put into scope via stringification
@@ -77,6 +77,7 @@ function getLinkElementsInDOM() {

return linkElements;
}
/* c8 ignore stop */

class LinkElements extends Gatherer {
/**
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/meta-elements.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const pageFunctions = require('../../lib/page-functions.js');

/* globals getElementsInDocument */

/* istanbul ignore next */
/* c8 ignore start */
function collectMetaElements() {
// @ts-expect-error - getElementsInDocument put into scope via stringification
const metas = /** @type {HTMLMetaElement[]} */ (getElementsInDocument('head meta'));
@@ -30,6 +30,7 @@ function collectMetaElements() {
};
});
}
/* c8 ignore stop */

class MetaElements extends Gatherer {
/**
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/script-elements.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ const pageFunctions = require('../../lib/page-functions.js');
/**
* @return {LH.Artifacts['ScriptElements']}
*/
/* istanbul ignore next */
/* c8 ignore start */
function collectAllScriptElements() {
/** @type {HTMLScriptElement[]} */
// @ts-expect-error - getElementsInDocument put into scope via stringification
@@ -36,6 +36,7 @@ function collectAllScriptElements() {
};
});
}
/* c8 ignore stop */

/**
* @template T, U
3 changes: 2 additions & 1 deletion lighthouse-core/gather/gatherers/seo/robots-txt.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const Gatherer = require('../gatherer.js');
/* global fetch, URL, location */

/** @return {Promise<LH.Artifacts['RobotsTxt']>} */
/* istanbul ignore next */
/* c8 ignore start */
async function getRobotsTxtContent() {
try {
const response = await fetch(new URL('/robots.txt', location.href).href);
@@ -24,6 +24,7 @@ async function getRobotsTxtContent() {
return {status: null, content: null};
}
}
/* c8 ignore stop */


class RobotsTxt extends Gatherer {
Loading