Skip to content

Commit

Permalink
Merge branch 'main' into format-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccar authored Sep 24, 2024
2 parents 5fa5196 + 78a3f55 commit bbdf8d8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/lighthouse-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ jobs:
run: yarn install
- name: Build pages
run: yarn build
- name: Build urls
run: node ./lighthouse/lighthouse-get-urls.js
- name: Run Lighthouse CI
run: ./lighthouse/lighthouse.sh
run: |
npm install -g @lhci/[email protected]
lhci autorun --config=./lighthouse/lighthouserc.js
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ yarn start

Once the server has started, navigate to <http://localhost:3030>

## Lighthouse Testing - local

This project uses [LHCI](https://www.npmjs.com/package/@lhci/cli).

```bash
yarn global add @lhci/cli
yarn test-lighthouse
```

## Testing - macros and scripts

This project uses [jest](https://jestjs.io/docs/cli) and supports its command line options.
Expand Down
7 changes: 4 additions & 3 deletions lighthouse/lighthouse-get-urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ async function getURLs() {
for (const directory of directories) {
const folders = await readdir(directory.path);
for (const folder of folders) {
const files = await glob(`${directory.path}/${folder}/**/*.html`, { ignore: `${directory.path}/${folder}/index.html` });
for (const file of files) {
data.urls.push(file.replace('./build/', 'http://localhost:9000/'));
const files = await glob(`${directory.path}/${folder}/**/*.html`);
const filteredFiles = files.filter((path) => !path.includes('index.html') && !path.includes('example-skip-to-content.html'));
for (const file of filteredFiles) {
data.urls.push(file.replace('build/', 'http://localhost/'));
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions lighthouse/lighthouse.sh

This file was deleted.

2 changes: 2 additions & 0 deletions lighthouse/lighthouserc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = {
ci: {
collect: {
staticDistDir: './build',
url: require('./urls.json').urls,
numberOfRuns: 1,
settings: {
onlyCategories: ['accessibility'],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"test:no-build": "TEST_PORT=3020 TEST_WITH_PUPPETEER=1 jest '.*\\.spec\\.js'",
"test:with-log": "yarn test --no-color 2>test.log",
"test:start-server": "TEST_PORT=3020 gulp start-dev-server",
"test-lighthouse": "yarn build && node ./lighthouse/lighthouse-get-urls.js && lhci autorun --config=./lighthouse/lighthouserc.js",
"build": "yarn && yarn tidy-clean && NODE_ENV=production gulp build",
"build-serve": "yarn build && gulp start-dev-server",
"npm-bundle": "NODE_ENV=production yarn tidy-clean && NODE_ENV=production gulp build-package && babel-node ci/generate-npm-package.js",
Expand Down

0 comments on commit bbdf8d8

Please sign in to comment.