mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-22 17:23:22 +01:00
Merge pull request #91 from kremalicious/fix/lighthouse
lighthouse test CI fix
This commit is contained in:
commit
97cce46a9a
@ -38,7 +38,7 @@ The whole [portfolio](https://matthiaskretschmann.com) is a React-based Single P
|
||||
|
||||
### ⛵️ Lighthouse score
|
||||
|
||||
[![Lighthouse scores](https://lighthouse.now.sh/?perf=100&pwa=100&a11y=100&bp=100&seo=100)](https://travis-ci.com/kremalicious/portfolio)
|
||||
![Lighthouse scores](https://lighthouse.now.sh/?perf=100&pwa=100&a11y=100&bp=100&seo=100)
|
||||
|
||||
### 💍 One data file to rule all pages
|
||||
|
||||
@ -113,7 +113,7 @@ All SVG assets under `src/images/` will be converted to React components with th
|
||||
```js
|
||||
import { ReactComponent as Logo } from './components/svg/Logo'
|
||||
|
||||
<Logo />
|
||||
return <Logo />
|
||||
```
|
||||
|
||||
### 🍬 Typekit component
|
||||
@ -167,7 +167,7 @@ Then continue modifying the new entry in [`data/projects.yml`](data/projects.yml
|
||||
|
||||
Finally, add as many images as needed with the file name format and put into `src/images/`:
|
||||
|
||||
```
|
||||
```text
|
||||
portfolio-SLUG-01.png
|
||||
portfolio-SLUG-02.png
|
||||
portfolio-SLUG-03.png
|
||||
|
16
package.json
16
package.json
@ -17,7 +17,7 @@
|
||||
"dev": "./node_modules/gatsby/dist/bin/gatsby.js develop --host 0.0.0.0",
|
||||
"format": "prettier --write 'src/**/*.{js,jsx}'",
|
||||
"format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'",
|
||||
"test": "npm run lint && ./node_modules/.bin/ava **/*.test.js --verbose",
|
||||
"test": "npm run lint",
|
||||
"deploy": "./scripts/deploy.sh",
|
||||
"new": "babel-node ./scripts/new.js"
|
||||
},
|
||||
@ -56,25 +56,21 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/node": "^7.2.2",
|
||||
"@babel/polyfill": "^7.2.5",
|
||||
"@babel/preset-env": "^7.2.3",
|
||||
"@svgr/webpack": "^4.1.0",
|
||||
"ava": "^1.1.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"chrome-launcher": "^0.10.5",
|
||||
"eslint": "^5.12.0",
|
||||
"eslint-config-prettier": "^3.4.0",
|
||||
"eslint": "^5.12.1",
|
||||
"eslint-config-prettier": "^3.6.0",
|
||||
"eslint-loader": "^2.1.1",
|
||||
"eslint-plugin-graphql": "^3.0.1",
|
||||
"eslint-plugin-prettier": "^3.0.1",
|
||||
"eslint-plugin-react": "^7.12.3",
|
||||
"lighthouse": "^4.0.0",
|
||||
"eslint-plugin-react": "^7.12.4",
|
||||
"ora": "^3.0.0",
|
||||
"prepend": "^1.0.2",
|
||||
"prettier": "^1.15.3",
|
||||
"prettier": "^1.16.0",
|
||||
"prettier-stylelint": "^0.4.2",
|
||||
"slugify": "^1.3.4",
|
||||
"stylelint": "^9.10.0",
|
||||
"stylelint": "^9.10.1",
|
||||
"stylelint-config-css-modules": "^1.3.0",
|
||||
"stylelint-config-standard": "^18.2.0",
|
||||
"why-did-you-update": "^1.0.6"
|
||||
|
@ -1,56 +0,0 @@
|
||||
import '@babel/polyfill'
|
||||
import * as chromeLauncher from 'chrome-launcher'
|
||||
import test from 'ava'
|
||||
import lighthouse from 'lighthouse'
|
||||
import { siteMetadata } from '../gatsby-config'
|
||||
|
||||
const launchChromeAndRunLighthouse = (
|
||||
url,
|
||||
opts = { chromeFlags: ['--headless'] },
|
||||
config = null
|
||||
) =>
|
||||
chromeLauncher
|
||||
.launch({ chromeFlags: opts.chromeFlags })
|
||||
.then(async chrome => {
|
||||
opts.port = chrome.port
|
||||
const results = await lighthouse(url, opts, config)
|
||||
await chrome.kill()
|
||||
return results.lhr
|
||||
})
|
||||
|
||||
let scores
|
||||
|
||||
test.before(async () => {
|
||||
console.log(`Auditing ${siteMetadata.siteUrl}.\n`) // eslint-disable-line no-console
|
||||
scores = await launchChromeAndRunLighthouse(siteMetadata.siteUrl).then(
|
||||
({ categories }) => categories
|
||||
)
|
||||
})
|
||||
|
||||
const logScore = score => `Is ${score * 100}.`
|
||||
|
||||
const testOutput = (t, metric) => {
|
||||
const { score } = scores[metric]
|
||||
t.log(logScore(score))
|
||||
return score >= 0.9 ? t.pass() : t.fail()
|
||||
}
|
||||
|
||||
test('Performance Score above 90', t => {
|
||||
testOutput(t, 'performance')
|
||||
})
|
||||
|
||||
test('PWA Score above 90', t => {
|
||||
testOutput(t, 'pwa')
|
||||
})
|
||||
|
||||
test('Accessibility Score above 90', t => {
|
||||
testOutput(t, 'accessibility')
|
||||
})
|
||||
|
||||
test('Best Practices Score above 90', t => {
|
||||
testOutput(t, 'best-practices')
|
||||
})
|
||||
|
||||
test('SEO Score above 90', t => {
|
||||
testOutput(t, 'seo')
|
||||
})
|
@ -50,6 +50,11 @@ const LinkIcon = ({ title, type, ...props }) => {
|
||||
}
|
||||
}
|
||||
|
||||
LinkIcon.propTypes = {
|
||||
title: PropTypes.string,
|
||||
type: PropTypes.string
|
||||
}
|
||||
|
||||
export default class ProjectLinks extends PureComponent {
|
||||
static propTypes = {
|
||||
links: PropTypes.array
|
||||
|
Loading…
Reference in New Issue
Block a user