Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

프론트엔드 E2E 테스트 - playwright 설정 #644

Merged
merged 5 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/frontend_playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Frontend Playwright

on:
push:
branches:
- dev/fe

jobs:
test:
timeout-minutes: 60
runs-on:
- self-hosted
- spring
- develop
env:
frontend-directory: ./frontend

steps:
- uses: actions/checkout@v4

- name: 노드 환경 사용
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: 환경 파일 생성
run: |
if [ "${{ github.ref_name }}" == "main" ]; then
echo "REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}" > ${{ env.frontend-directory }}/.env.production
echo "REACT_APP_BASE_URL=${{ secrets.REACT_APP_BASE_URL }}" >> ${{ env.frontend-directory }}/.env.production
else
echo "REACT_APP_API_URL=${{ secrets.REACT_APP_BETA_API_URL }}" > ${{ env.frontend-directory }}/.env.development
echo "REACT_APP_BASE_URL=${{ secrets.REACT_APP_BETA_BASE_URL }}" >> ${{ env.frontend-directory }}/.env.development
fi

echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> ${{ env.frontend-directory }}/.env.production
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> ${{ env.frontend-directory }}/.env.production
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> ${{ env.frontend-directory }}/.env.sentry-build-plugin

- name: 환경 파일 권한 설정
run: chmod 644 ${{ env.frontend-directory }}/.env.*

- name: npm 패키지 설치
run: npm ci
working-directory: ${{ env.frontend-directory }}

- name: Playwright Browsers 설치
run: npx playwright install --with-deps
working-directory: ${{ env.frontend-directory }}

- name: Playwright 테스트 실행
run: npx playwright test

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ dist
*.crt
*.key
*.csr
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
15 changes: 15 additions & 0 deletions frontend/e2eTests/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { test } from '@playwright/test';

test('코드잽 서비스에 들어가서 로그인 할 수 있다.', async ({ page }) => {
await page.goto('/');
await page.getByRole('button', { name: '로그인', exact: true }).click();
await page
.locator('div')
.filter({ hasText: /^아이디 \(닉네임\)$/ })
.locator('div')
.click();
await page.locator('input[type="text"]').fill('ll');
await page.locator('input[type="text"]').press('Tab');
await page.locator('input[type="password"]').fill('llll1111');
await page.locator('form').getByRole('button', { name: '로그인' }).click();
});
1 change: 1 addition & 0 deletions frontend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const config: Config = {
'react-syntax-highlighter/dist/esm': 'react-syntax-highlighter/dist/cjs',
},
transformIgnorePatterns: ['/node_modules/(?!react-syntax-highlighter)'],
testPathIgnorePatterns: ['/node_modules/', '/e2eTests/', '/tests-examples/'],
};

export default config;
Loading