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(fixtures): introduce script to update the report fixtures #4793

Merged
merged 10 commits into from
Mar 21, 2018
Merged
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ last-run-results.html
*.report.pretty
*.artifacts.log

!lighthouse-core/test/results/artifacts/*.trace.json
!lighthouse-core/test/results/artifacts/*.devtoolslog.json

latest-run

closure-error.log
Expand Down
17 changes: 14 additions & 3 deletions lighthouse-cli/test/fixtures/static-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
// @ts-nocheck
'use strict';

/* eslint-disable no-console */
Expand Down Expand Up @@ -122,6 +123,16 @@ const serverForOffline = http.createServer(requestHandler);
serverForOnline.on('error', e => console.error(e.code, e));
serverForOffline.on('error', e => console.error(e.code, e));

// Listen
serverForOnline.listen(10200, 'localhost');
serverForOffline.listen(10503, 'localhost');

// If called via `node static-server.js` then start listening, otherwise, just expose the servers
if (require.main === module) {
// Start listening
serverForOnline.listen(10200, 'localhost');
serverForOffline.listen(10503, 'localhost');
} else {
module.exports = {
server: serverForOnline,
serverForOffline,
};
}

29 changes: 29 additions & 0 deletions lighthouse-core/scripts/update-report-fixtures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @license Copyright 2018 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

const cli = require('../../lighthouse-cli/run');

const {server} = require('../../lighthouse-cli/test/fixtures/static-server');

/**
* Update the report artifacts
*/
async function update() {
// get an available port
server.listen(0, 'localhost');
const port = await new Promise(res => server.on('listening', () => res(server.address().port)));

const url = `http://localhost:${port}/dobetterweb/dbw_tester.html`;
const flags = {
gatherMode: 'lighthouse-core/test/results/artifacts',
};
// @ts-ignore Remove when we fix Flags typing
await cli.runLighthouse(url, flags, undefined);
await new Promise(res => server.close(res));
}

update();
2,525 changes: 2,525 additions & 0 deletions lighthouse-core/test/results/artifacts/artifacts.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

14,665 changes: 14,665 additions & 0 deletions lighthouse-core/test/results/artifacts/defaultPass.trace.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"method":"Network.requestWillBeSent","params":{"requestId":"B153A75C1DEF181D4A3B369563BFF20C","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","documentURL":"http://localhost:10200/dobetterweb/dbw_tester.html","request":{"url":"http://localhost:10200/dobetterweb/dbw_tester.html","method":"GET","headers":{"Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/61.0.3116.0 Mobile Safari/537.36","X-DevTools-Emulate-Network-Conditions-Client-Id":"A36E31E517F452A18C51AA32F4163A8C"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":185617.176299,"wallTime":1519974796.775882,"initiator":{"type":"other"},"type":"Document","frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.responseReceived","params":{"requestId":"B153A75C1DEF181D4A3B369563BFF20C","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","timestamp":185617.179082,"type":"Document","response":{"url":"http://localhost:10200/dobetterweb/dbw_tester.html","status":200,"statusText":"OK","headers":{"Date":"Fri, 02 Mar 2018 07:13:16 GMT","Connection":"keep-alive","Transfer-Encoding":"chunked"},"headersText":"HTTP/1.1 200 OK\r\nDate: Fri, 02 Mar 2018 07:13:16 GMT\r\nConnection: keep-alive\r\nTransfer-Encoding: chunked\r\n\r\n","mimeType":"text/html","requestHeaders":{"Host":"localhost:10200","Connection":"keep-alive","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/61.0.3116.0 Mobile Safari/537.36","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","Accept-Encoding":"gzip, deflate, br","Accept-Language":"en-US,en;q=0.9"},"requestHeadersText":"GET /dobetterweb/dbw_tester.html HTTP/1.1\r\nHost: localhost:10200\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/61.0.3116.0 Mobile Safari/537.36\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\r\nAccept-Encoding: gzip, deflate, br\r\nAccept-Language: en-US,en;q=0.9\r\n","connectionReused":true,"connectionId":221,"remoteIPAddress":"127.0.0.1","remotePort":10200,"fromDiskCache":false,"fromServiceWorker":false,"encodedDataLength":108,"timing":{"requestTime":185617.176621,"proxyStart":-1,"proxyEnd":-1,"dnsStart":-1,"dnsEnd":-1,"connectStart":-1,"connectEnd":-1,"sslStart":-1,"sslEnd":-1,"workerStart":-1,"workerReady":-1,"sendStart":0.838,"sendEnd":0.873,"pushStart":0,"pushEnd":0,"receiveHeadersEnd":1.759},"protocol":"http/1.1","securityState":"neutral"},"frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Page.frameStartedLoading","params":{"frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.dataReceived","params":{"requestId":"B153A75C1DEF181D4A3B369563BFF20C","timestamp":185617.180942,"dataLength":3982,"encodedDataLength":0}},{"method":"Page.frameNavigated","params":{"frame":{"id":"A36E31E517F452A18C51AA32F4163A8C","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","url":"http://localhost:10200/dobetterweb/dbw_tester.html","securityOrigin":"http://localhost:10200","mimeType":"text/html"}}},{"method":"Network.dataReceived","params":{"requestId":"B153A75C1DEF181D4A3B369563BFF20C","timestamp":185617.185044,"dataLength":8537,"encodedDataLength":0}},{"method":"Network.loadingFinished","params":{"requestId":"B153A75C1DEF181D4A3B369563BFF20C","timestamp":185617.181093,"encodedDataLength":12640,"blockedCrossSiteDocument":false}},{"method":"Network.requestWillBeSent","params":{"requestId":"75994.66","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","documentURL":"http://localhost:10200/dobetterweb/dbw_tester.html","request":{"url":"http://localhost:10200/dobetterweb/dbw_tester.css?delay=100","method":"GET","headers":{"Referer":"http://localhost:10200/dobetterweb/dbw_tester.html"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":185617.186619,"wallTime":1519974796.7862,"initiator":{"type":"parser","url":"http://localhost:10200/dobetterweb/dbw_tester.html","lineNumber":22},"type":"Stylesheet","frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.loadingFailed","params":{"requestId":"75994.66","timestamp":185617.186622,"type":"Stylesheet","errorText":"","canceled":false,"blockedReason":"inspector"}},{"method":"Network.requestWillBeSent","params":{"requestId":"75994.68","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","documentURL":"http://localhost:10200/dobetterweb/dbw_tester.html","request":{"url":"http://localhost:10200/dobetterweb/unknown404.css?delay=200","method":"GET","headers":{"Referer":"http://localhost:10200/dobetterweb/dbw_tester.html"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":185617.186715,"wallTime":1519974796.7863,"initiator":{"type":"parser","url":"http://localhost:10200/dobetterweb/dbw_tester.html","lineNumber":23},"type":"Stylesheet","frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.loadingFailed","params":{"requestId":"75994.68","timestamp":185617.186717,"type":"Stylesheet","errorText":"","canceled":false,"blockedReason":"inspector"}},{"method":"Network.requestWillBeSent","params":{"requestId":"75994.70","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","documentURL":"http://localhost:10200/dobetterweb/dbw_tester.html","request":{"url":"http://localhost:10200/dobetterweb/dbw_tester.css?delay=2200","method":"GET","headers":{"Referer":"http://localhost:10200/dobetterweb/dbw_tester.html"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":185617.186799,"wallTime":1519974796.78638,"initiator":{"type":"parser","url":"http://localhost:10200/dobetterweb/dbw_tester.html","lineNumber":24},"type":"Stylesheet","frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.loadingFailed","params":{"requestId":"75994.70","timestamp":185617.186802,"type":"Stylesheet","errorText":"","canceled":false,"blockedReason":"inspector"}},{"method":"Network.requestWillBeSent","params":{"requestId":"75994.72","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","documentURL":"http://localhost:10200/dobetterweb/dbw_tester.html","request":{"url":"http://localhost:10200/dobetterweb/dbw_partial_a.html?delay=200","method":"GET","headers":{"Referer":"http://localhost:10200/dobetterweb/dbw_tester.html","Origin":"http://localhost:10200"},"mixedContentType":"none","initialPriority":"High","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":185617.186917,"wallTime":1519974796.7865,"initiator":{"type":"parser","url":"http://localhost:10200/dobetterweb/dbw_tester.html","lineNumber":26},"type":"Document","frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.loadingFailed","params":{"requestId":"75994.72","timestamp":185617.186919,"type":"Document","errorText":"","canceled":false,"blockedReason":"csp"}},{"method":"Network.requestWillBeSent","params":{"requestId":"75994.74","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","documentURL":"http://localhost:10200/dobetterweb/dbw_tester.html","request":{"url":"http://localhost:10200/dobetterweb/dbw_partial_b.html?delay=200&isasync","method":"GET","headers":{"Referer":"http://localhost:10200/dobetterweb/dbw_tester.html","Origin":"http://localhost:10200"},"mixedContentType":"none","initialPriority":"High","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":185617.187006,"wallTime":1519974796.78659,"initiator":{"type":"parser","url":"http://localhost:10200/dobetterweb/dbw_tester.html","lineNumber":27},"type":"Document","frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.loadingFailed","params":{"requestId":"75994.74","timestamp":185617.187008,"type":"Document","errorText":"","canceled":false,"blockedReason":"csp"}},{"method":"Network.requestWillBeSent","params":{"requestId":"75994.76","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","documentURL":"http://localhost:10200/dobetterweb/dbw_tester.html","request":{"url":"http://localhost:10200/dobetterweb/dbw_tester.css?delay=2000&async=true","method":"GET","headers":{"Referer":"http://localhost:10200/dobetterweb/dbw_tester.html"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade","isLinkPreload":true},"timestamp":185617.187098,"wallTime":1519974796.78668,"initiator":{"type":"parser","url":"http://localhost:10200/dobetterweb/dbw_tester.html","lineNumber":30},"type":"Stylesheet","frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.loadingFailed","params":{"requestId":"75994.76","timestamp":185617.1871,"type":"Stylesheet","errorText":"","canceled":false,"blockedReason":"inspector"}},{"method":"Network.requestWillBeSent","params":{"requestId":"75994.78","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","documentURL":"http://localhost:10200/dobetterweb/dbw_tester.html","request":{"url":"http://localhost:10200/dobetterweb/lighthouse-480x318.jpg","method":"GET","headers":{"Referer":"http://localhost:10200/dobetterweb/dbw_tester.html"},"mixedContentType":"none","initialPriority":"Low","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":185617.187496,"wallTime":1519974796.78708,"initiator":{"type":"parser","url":"http://localhost:10200/dobetterweb/dbw_tester.html","lineNumber":133},"type":"Image","frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.loadingFailed","params":{"requestId":"75994.78","timestamp":185617.187499,"type":"Image","errorText":"","canceled":false,"blockedReason":"inspector"}},{"method":"Network.requestWillBeSent","params":{"requestId":"75994.80","loaderId":"B153A75C1DEF181D4A3B369563BFF20C","documentURL":"http://localhost:10200/dobetterweb/dbw_tester.html","request":{"url":"http://localhost:10200/dobetterweb/lighthouse-480x318.jpg","method":"GET","headers":{"Referer":"http://localhost:10200/dobetterweb/dbw_tester.html"},"mixedContentType":"none","initialPriority":"Low","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":185617.187603,"wallTime":1519974796.78719,"initiator":{"type":"parser","url":"http://localhost:10200/dobetterweb/dbw_tester.html","lineNumber":135},"type":"Image","frameId":"A36E31E517F452A18C51AA32F4163A8C"}},{"method":"Network.loadingFailed","params":{"requestId":"75994.80","timestamp":185617.187605,"type":"Image","errorText":"","canceled":false,"blockedReason":"inspector"}},{"method":"Page.domContentEventFired","params":{"timestamp":185617.189111}},{"method":"Page.loadEventFired","params":{"timestamp":185617.189281}},{"method":"Page.frameStoppedLoading","params":{"frameId":"A36E31E517F452A18C51AA32F4163A8C"}}]
Loading