Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add collect option to set number of pages to autodiscover (#…
…434)
- Loading branch information
Showing
11 changed files
with
183 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/** | ||
* @license Copyright 2019 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'; | ||
|
||
jest.retryTimes(3); | ||
|
||
/* eslint-env jest */ | ||
|
||
const path = require('path'); | ||
const {runCLI} = require('./test-utils.js'); | ||
|
||
describe('Lighthouse CI collect CLI', () => { | ||
describe('with URLs', () => { | ||
const staticDistDir = path.join(__dirname, 'fixtures/collect-static-dir-with-urls'); | ||
it('should collect a static dir with explicit URLs', async () => { | ||
const {stdout, stderr, status} = await runCLI( | ||
['collect', '-n=1', '--staticDistDir=./', '--url=/child/grandchild.html'], | ||
{ | ||
cwd: staticDistDir, | ||
} | ||
); | ||
expect(stdout).toMatchInlineSnapshot(` | ||
"Started a web server on port XXXX... | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/child/grandchild.html | ||
Run #1...done. | ||
Done running Lighthouse! | ||
" | ||
`); | ||
expect(stderr).toMatchInlineSnapshot(`""`); | ||
expect(status).toEqual(0); | ||
}, 180000); | ||
}); | ||
|
||
describe('with autodiscover limit', () => { | ||
const staticDistDir = path.join(__dirname, 'fixtures/collect-static-dir-autodiscover-limit'); | ||
it('should collect a single page from static dir', async () => { | ||
const {stdout, stderr, status} = await runCLI( | ||
['collect', '-n=1', '--staticDistDir=./', '--maxAutodiscoverUrls=1'], | ||
{ | ||
cwd: staticDistDir, | ||
} | ||
); | ||
expect(stdout).toMatchInlineSnapshot(` | ||
"Started a web server on port XXXX... | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/board.html | ||
Run #1...done. | ||
Done running Lighthouse! | ||
" | ||
`); | ||
expect(stderr).toMatchInlineSnapshot(`""`); | ||
expect(status).toEqual(0); | ||
}, 180000); | ||
|
||
it('should collect all available pages from static dir', async () => { | ||
const {stdout, stderr, status} = await runCLI( | ||
['collect', '-n=1', '--staticDistDir=./', '--maxAutodiscoverUrls=0'], | ||
{ | ||
cwd: staticDistDir, | ||
} | ||
); | ||
expect(stdout).toMatchInlineSnapshot(` | ||
"Started a web server on port XXXX... | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/board.html | ||
Run #1...done. | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/checkout.html | ||
Run #1...done. | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/index.html | ||
Run #1...done. | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/jobs.html | ||
Run #1...done. | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/shop.html | ||
Run #1...done. | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/team.html | ||
Run #1...done. | ||
Done running Lighthouse! | ||
" | ||
`); | ||
expect(stderr).toMatchInlineSnapshot(`""`); | ||
expect(status).toEqual(0); | ||
}, 180000); | ||
}); | ||
describe('by default', () => { | ||
const staticDistDir = path.join(__dirname, 'fixtures/collect-static-dir-autodiscover-limit'); | ||
|
||
it('should collect 5 pages from static dir', async () => { | ||
const {stdout, stderr, status} = await runCLI(['collect', '-n=1', '--staticDistDir=./'], { | ||
cwd: staticDistDir, | ||
}); | ||
expect(stdout).toMatchInlineSnapshot(` | ||
"Started a web server on port XXXX... | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/board.html | ||
Run #1...done. | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/checkout.html | ||
Run #1...done. | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/index.html | ||
Run #1...done. | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/jobs.html | ||
Run #1...done. | ||
Running Lighthouse 1 time(s) on http://localhost:XXXX/shop.html | ||
Run #1...done. | ||
Done running Lighthouse! | ||
" | ||
`); | ||
expect(stderr).toMatchInlineSnapshot(`""`); | ||
expect(status).toEqual(0); | ||
}, 180000); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/cli/test/fixtures/collect-static-dir-autodiscover-limit/board.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>board test page for staticDistDir usage</title> | ||
</head> | ||
<body> | ||
test | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
packages/cli/test/fixtures/collect-static-dir-autodiscover-limit/checkout.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>checkout test page for staticDistDir usage</title> | ||
</head> | ||
<body> | ||
test | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
packages/cli/test/fixtures/collect-static-dir-autodiscover-limit/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>index test page for staticDistDir usage</title> | ||
</head> | ||
<body> | ||
test | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
packages/cli/test/fixtures/collect-static-dir-autodiscover-limit/jobs.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>jobs test page for staticDistDir usage</title> | ||
</head> | ||
<body> | ||
test | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
packages/cli/test/fixtures/collect-static-dir-autodiscover-limit/shop.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>shop test page for staticDistDir usage</title> | ||
</head> | ||
<body> | ||
test | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
packages/cli/test/fixtures/collect-static-dir-autodiscover-limit/team.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>team test page for staticDistDir usage</title> | ||
</head> | ||
<body> | ||
test | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters