Skip to content

Commit

Permalink
added lighthouse CI test and playwrighgt test
Browse files Browse the repository at this point in the history
  • Loading branch information
shreybaz committed Apr 24, 2024
0 parents commit a68777f
Show file tree
Hide file tree
Showing 9 changed files with 874 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Generate lighthouse test report on PR
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
automation-test:
runs-on: ubuntu-latest
env:
COOKIE_KEY: '1267b291500365c42043e04bc69cf24a31495bd8936fc8d6794283675e288fad755971922d45cf1ca0b438df4fc847f39cb0b2aceb3a45673eff231cddb88dc9'

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install

- name: Install Lighthouse
run: npm install -g @lhci/cli@0.13.x

- name: Run Lighthouse
# run: lhci autorun --upload.githubToken="$LHCI_GITHUB_TOKEN" || echo "LHCI failed!"
run: lhci autorun
# env:
# LHCI_GITHUB_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}

- name: install playwright
run: npx playwright install

- name: run playwright
id: tests
# run: TESTPARAM=${{secrets.MAIL_PASSWORD}} npx playwright test --project=firefox
run: npx playwright test --project=firefox

# - name: Check test result and comment
# uses: peter-evans/create-or-update-comment@v1
# with:
# token: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
# issue-number: ${{ github.event.pull_request.number }}
# body: |
# ${{ steps.tests.outcome == '2 passed' && 'Test passed :heavy_check_mark:' || 'Test failed, Please check logs for details.' }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/.lighthouseci
Empty file added README.md
Empty file.
16 changes: 16 additions & 0 deletions lighthouserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
ci: {
collect: {
url: ['https://yral.com/'],
},
upload: {
target: 'temporary-public-storage',
},
assert: {
assertions: {
"categories:performance": ["warn", {"minScore": 0.3}],
"categories:accessibility": ["warn", {"minScore": 0.5}]
},
},
},
};
87 changes: 87 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
"playwright": "^1.43.1"
},
"devDependencies": {
"@playwright/test": "^1.43.1",
"@types/node": "^20.12.7"
},
"scripts": {}
}
79 changes: 79 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});

Loading

0 comments on commit a68777f

Please sign in to comment.