Skip to content

Commit

Permalink
Update reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Dec 13, 2024
1 parent d647885 commit 5c1535c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 36 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/e2e_api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ env:
SHA: ${{ github.event.pull_request.head.sha }}
SYSTEM_INFO: ./tests/pw/playwright/systemInfo.json
API_TEST_RESULT: ./tests/pw/playwright-report/api/summary-report/results.json
E2E_TEST_RESULT: ./tests/pw/playwright-report/e2e/summary-report/results.json
E2E_TEST_RESULT: ./tests/pw/playwright-report/e2e/${{ matrix.group }}/summary-report/results.json
API_COVERAGE: ./tests/pw/playwright-report/api/coverage-report/coverage.json
E2E_COVERAGE: ./tests/pw/playwright-report/e2e/coverage-report/coverage.json
E2E_COVERAGE: ./tests/pw/playwright-report/e2e/${{ matrix.group }}/coverage-report/coverage.json

jobs:
tests:
name: e2e_api tests
name: e2e_api tests-${{ matrix.group }}
runs-on: ubuntu-latest
strategy:
matrix:
test_group: [e2e_1, e2e_2]
group: [e2e_1, e2e_2]

steps:
- name: Checkout testing repo
Expand Down Expand Up @@ -118,17 +118,17 @@ jobs:
cd tests/pw
npm run start:env
# Set permalink structure
- name: Set Permalink structure
working-directory: tests/pw
run: |
npm run wp-env run tests-cli wp rewrite structure /%postname%/
# # Set permalink structure
# - name: Set Permalink structure
# working-directory: tests/pw
# run: |
# npm run wp-env run tests-cli wp rewrite structure /%postname%/

# Activate theme
- name: Activate theme:Storefront
working-directory: tests/pw
run: |
npm run wp-env run tests-cli wp theme activate storefront
# # Activate theme
# - name: Activate theme:Storefront
# working-directory: tests/pw
# run: |
# npm run wp-env run tests-cli wp theme activate storefront

# Get Playwright version
- name: Get installed Playwright version
Expand Down Expand Up @@ -164,16 +164,16 @@ jobs:
# npm run pw:deps-only

# Run e2e tests
- name: 🧪 Run e2e tests ${{ matrix.group }}
- name: 🧪 Run e2e tests-${{ matrix.group }}
id: e2e-test
if: success() && (github.event_name != 'workflow_dispatch' || ( github.event_name == 'workflow_dispatch' && (github.event.inputs.testsuite == 'E2E' || github.event.inputs.testsuite == 'All')))
timeout-minutes: 40
timeout-minutes: 30
working-directory: tests/pw
run: |
if [[ "${{ matrix.group }}" == e2e_1 ]]; then
npx playwright test --project=${{ matrix.group }} --config=e2e.config.ts
elif [[ "${{ matrix.group }}" == a2e_2 ]]; then
npx playwright test --project=${{ matrix.group }} --config=e2e.config.ts
if [[ ${{ matrix.group }} == e2e_1 ]]; then
GROUP=${{ matrix.group }} npx playwright test --project=${{ matrix.group }} --config=e2e.config.ts
elif [[ ${{ matrix.group }} == e2e_2 ]]; then
GROUP=${{ matrix.group }} npx playwright test --project=${{ matrix.group }} --config=e2e.config.ts
fi
# Run e2e coverage
Expand All @@ -184,13 +184,13 @@ jobs:
npm run test:e2e:coverage
# Run api tests
- name: 🧪 Run api tests
id: api-test
if: always() && steps.wp-env.outcome == 'success' && ( github.event_name != 'workflow_dispatch' || ( github.event_name == 'workflow_dispatch' && (github.event.inputs.testsuite == 'API' || github.event.inputs.testsuite == 'All')))
timeout-minutes: 5
working-directory: tests/pw
run: |
npm run test:api
# - name: 🧪 Run api tests
# id: api-test
# if: always() && steps.wp-env.outcome == 'success' && ( github.event_name != 'workflow_dispatch' || ( github.event_name == 'workflow_dispatch' && (github.event.inputs.testsuite == 'API' || github.event.inputs.testsuite == 'All')))
# timeout-minutes: 5
# working-directory: tests/pw
# run: |
# npm run test:api

# Prepare test summary
- name: Prepare test summary
Expand Down Expand Up @@ -236,7 +236,7 @@ jobs:
uses: actions/upload-artifact@v4
if: always() && steps.debug-log.outcome == 'success'
with:
name: test-artifact
name: test-artifact-${{ matrix.group }}
path: |
tests/pw/wp-data
tests/pw/playwright
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/api.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default defineConfig({
/* Configure reporters */
reporter: CI
? [
['github'],
// ['github'],
['html', { open: 'never', outputFolder: 'playwright-report/api/html-report' }],
// ['junit', { outputFile: 'playwright-report/api/junit-report/api-results.xml' }],
['list', { printSteps: true }],
Expand Down
6 changes: 2 additions & 4 deletions tests/pw/e2e.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig, devices, expect } from '@playwright/test';
import { customExpect } from '@utils/pwMatchers';
import 'dotenv/config';
const { CI, NON_HEADLESS, BASE_URL, SLOWMO, NO_SETUP, DOKAN_PRO } = process.env;
const { CI, NON_HEADLESS, BASE_URL, SLOWMO, NO_SETUP, DOKAN_PRO, GROUP } = process.env;

export default defineConfig({
/* test directory */
Expand Down Expand Up @@ -59,7 +59,7 @@ export default defineConfig({
['html', { open: 'never', outputFolder: 'playwright-report/e2e/html-report' }],
// ['junit', { outputFile: 'playwright-report/e2e/junit-report/e2e-results.xml' }],
['list', { printSteps: true }],
['./utils/summaryReporter.ts', { outputFile: 'playwright-report/e2e/summary-report/results.json' }],
['./utils/summaryReporter.ts', { outputFile: `playwright-report/e2e/${GROUP}/summary-report/results.json` }],
],

use: {
Expand Down Expand Up @@ -151,7 +151,6 @@ export default defineConfig({
// teardown: NO_SETUP ? undefined : 'coverage_report',
},


// e2e_tests
{
name: 'e2e_1',
Expand All @@ -160,7 +159,6 @@ export default defineConfig({
dependencies: NO_SETUP ? [] : ['e2e_setup'],
},


// e2e_tests
{
name: 'e2e_2',
Expand Down
6 changes: 3 additions & 3 deletions tests/pw/tests/e2e/_coverage.teardown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs';
import path from 'path';
import { helpers } from '@utils/helpers';

const { DOKAN_PRO } = process.env;
const { DOKAN_PRO, GROUP } = process.env;

let executed_tests: string[] = [];

Expand All @@ -17,8 +17,8 @@ const uncoveredFeatures: string[] = [];

teardown.describe('get e2e test coverage', () => {
const feature_map = 'feature-map/feature-map.yml';
const outputFile = 'playwright-report/e2e/coverage-report/coverage.json';
const testReport = 'playwright-report/e2e/summary-report/results.json';
const outputFile = `playwright-report/e2e/${GROUP}/coverage-report/coverage.json`;
const testReport = `playwright-report/e2e/${GROUP}/summary-report/results.json`;

teardown('get coverage', { tag: ['@lite'] }, async () => {
executed_tests = helpers.readJson(testReport)?.tests;
Expand Down
1 change: 1 addition & 0 deletions tests/pw/types/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ declare global {
E2E_TEST_RESULT: string;
API_COVERAGE: string;
E2E_COVERAGE: string;
GROUP: string;
}
}
}

0 comments on commit 5c1535c

Please sign in to comment.