Add performance testing to Cypress results
This commit is contained in:
parent
74cbc949ea
commit
80ab351cbe
4
.github/workflows/browser-testing.yml
vendored
4
.github/workflows/browser-testing.yml
vendored
@ -9,7 +9,6 @@ on:
|
|||||||
- web/**
|
- web/**
|
||||||
jobs:
|
jobs:
|
||||||
cypress-run:
|
cypress-run:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- id: skip_check
|
- id: skip_check
|
||||||
@ -24,6 +23,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: '1.18.8'
|
go-version: '1.18.8'
|
||||||
|
|
||||||
|
- name: Install Google Chrome
|
||||||
|
run: sudo apt-get install google-chrome-stable
|
||||||
|
|
||||||
- name: Run Browser tests
|
- name: Run Browser tests
|
||||||
uses: nick-fields/retry@v2
|
uses: nick-fields/retry@v2
|
||||||
with:
|
with:
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
const { defineConfig } = require('cypress');
|
const { defineConfig } = require('cypress');
|
||||||
|
const { lighthouse, prepareAudit } = require('@cypress-audit/lighthouse');
|
||||||
|
|
||||||
module.exports = defineConfig({
|
module.exports = defineConfig({
|
||||||
projectId: 'wwi3xe',
|
projectId: 'wwi3xe',
|
||||||
e2e: {
|
e2e: {
|
||||||
setupNodeEvents(on, config) {
|
setupNodeEvents(on, config) {
|
||||||
// implement node event listeners here
|
on('before:browser:launch', (browser = {}, launchOptions) => {
|
||||||
|
prepareAudit(launchOptions);
|
||||||
|
});
|
||||||
|
|
||||||
|
on('task', {
|
||||||
|
lighthouse: lighthouse(),
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
describe('Lighthouse Metrics', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('http://localhost:8080');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Capture Metrics', () => {
|
||||||
|
cy.lighthouse({
|
||||||
|
accessibility: 97,
|
||||||
|
'best-practices': 97,
|
||||||
|
seo: 97,
|
||||||
|
performance: 90,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,14 @@
|
|||||||
|
describe('Lighthouse Metrics', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('http://localhost:8080');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Capture Metrics', () => {
|
||||||
|
cy.lighthouse({
|
||||||
|
accessibility: 97,
|
||||||
|
'best-practices': 97,
|
||||||
|
seo: 97,
|
||||||
|
performance: 60, // Once the performance issues are fixed revert this 90,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -23,3 +23,6 @@
|
|||||||
//
|
//
|
||||||
// -- This will overwrite an existing command --
|
// -- This will overwrite an existing command --
|
||||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||||
|
|
||||||
|
import 'cypress-audit/commands';
|
||||||
|
import '@cypress-audit/lighthouse/commands';
|
||||||
|
3770
test/automated/browser/package-lock.json
generated
3770
test/automated/browser/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,8 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cypress": "^10.10.0"
|
"@cypress-audit/lighthouse": "^1.3.1",
|
||||||
|
"cypress": "^10.10.0",
|
||||||
|
"cypress-audit": "^1.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,42 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
TEMP_DB=$(mktemp)
|
TEMP_DB=$(mktemp)
|
||||||
BUILD_ID=$((RANDOM % 7200 + 600))
|
BUILD_ID=$((RANDOM % 7200 + 600))
|
||||||
|
BROWSER="electron" #Default. Will try to use Google Chrome.
|
||||||
|
|
||||||
|
if hash google-chrome 2>/dev/null; then
|
||||||
|
BROWSER="chrome"
|
||||||
|
echo "Using Google Chrome as a browser."
|
||||||
|
else
|
||||||
|
echo "Google Chrome not found. Using Electron."
|
||||||
|
fi
|
||||||
|
|
||||||
# Change to the root directory of the repository
|
# Change to the root directory of the repository
|
||||||
cd "$(git rev-parse --show-toplevel)"
|
pushd "$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
# Bundle the updated web code into the server codebase.
|
# Bundle the updated web code into the server codebase.
|
||||||
echo "Bundling web code into server..."
|
if [ -z $SKIP_BUILD ]; then
|
||||||
./build/web/bundleWeb.sh >/dev/null
|
echo "Bundling web code into server..."
|
||||||
|
./build/web/bundleWeb.sh >/dev/null
|
||||||
|
else
|
||||||
|
echo "Skipping web build..."
|
||||||
|
fi
|
||||||
|
|
||||||
# Install the web test framework
|
# Install the web test framework
|
||||||
echo "Installing test dependencies..."
|
if [ -z "$SKIP_BUILD" ]; then
|
||||||
pushd test/automated/browser
|
echo "Installing test dependencies..."
|
||||||
npm install --quiet --no-progress
|
pushd test/automated/browser
|
||||||
|
npm install --quiet --no-progress
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
else
|
||||||
|
echo "Skipping dependencies installation"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
# Download a specific version of ffmpeg
|
# Download a specific version of ffmpeg
|
||||||
if [ ! -d "ffmpeg" ]; then
|
if [ ! -d "ffmpeg" ]; then
|
||||||
@ -35,6 +52,7 @@ fi
|
|||||||
# Build and run owncast from source
|
# Build and run owncast from source
|
||||||
echo "Building owncast..."
|
echo "Building owncast..."
|
||||||
go build -o owncast main.go
|
go build -o owncast main.go
|
||||||
|
|
||||||
echo "Running owncast..."
|
echo "Running owncast..."
|
||||||
./owncast -database "$TEMP_DB" &
|
./owncast -database "$TEMP_DB" &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
@ -42,9 +60,9 @@ SERVER_PID=$!
|
|||||||
pushd test/automated/browser
|
pushd test/automated/browser
|
||||||
|
|
||||||
# Run cypress browser tests for desktop
|
# Run cypress browser tests for desktop
|
||||||
npx cypress run --group "desktop-offline" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js"
|
npx cypress run --browser "$BROWSER" --group "desktop-offline" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js"
|
||||||
# Run cypress browser tests for mobile
|
# Run cypress browser tests for mobile
|
||||||
npx cypress run --group "mobile-offline" --ci-build-id $BUILD_ID --tag "mobile,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js" --config viewportWidth=375,viewportHeight=667
|
npx cypress run --browser "$BROWSER" --group "mobile-offline" --ci-build-id $BUILD_ID --tag "mobile,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js" --config viewportWidth=375,viewportHeight=667
|
||||||
|
|
||||||
# Start streaming the test file over RTMP to
|
# Start streaming the test file over RTMP to
|
||||||
# the local owncast instance.
|
# the local owncast instance.
|
||||||
@ -62,6 +80,6 @@ trap finish EXIT SIGHUP SIGINT SIGTERM SIGQUIT SIGABRT SIGTERM
|
|||||||
sleep 20
|
sleep 20
|
||||||
|
|
||||||
# Run cypress browser tests for desktop
|
# Run cypress browser tests for desktop
|
||||||
npx cypress run --group "desktop-online" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,online" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/online/*.cy.js"
|
npx cypress run --browser "$BROWSER" --group "desktop-online" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,online" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/online/*.cy.js"
|
||||||
# Run cypress browser tests for mobile
|
# Run cypress browser tests for mobile
|
||||||
npx cypress run --group "mobile-online" --ci-build-id $BUILD_ID --tag "mobile,online" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/online/*.cy.js" --config viewportWidth=375,viewportHeight=667
|
npx cypress run --browser "$BROWSER" --group "mobile-online" --ci-build-id $BUILD_ID --tag "mobile,online" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/online/*.cy.js" --config viewportWidth=375,viewportHeight=667
|
||||||
|
Loading…
x
Reference in New Issue
Block a user