Skip to content

Commit

Permalink
#74 Installed Playwright and add in to CI/CD pipeline (#92)
Browse files Browse the repository at this point in the history
* installed playwright and added into the CICD pipeline

* added in Playwright and RTL in ReadMe

* cleaned up package.json

* deleted commented code that was not used and updated file directory for tests

* deleted test examples directories and modified test files

* removed test result and playwright report from .gitignore

* installed newest dependencies

* added in action-setupv2 in ci.yml

* removed the line I added

* revert pnpm install back to pnpm ci

* modified ci.yml with cache

* revert changes back

* commented out mobile views

* indented playwright testing

* modified indentation of yaml file

* revert back identation

* revert changes

* added in different install

* removed test files

* removed test folders

* added in example test file

* removed test example

* added in path to ignore playwright tests

* removed test results and playwright report out of .gitignore
  • Loading branch information
vmaineng authored and Clue355 committed May 1, 2024
1 parent 64000c2 commit ae0bdb5
Show file tree
Hide file tree
Showing 9 changed files with 1,394 additions and 1,156 deletions.
26 changes: 25 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
push: true
tags: ghcr.io/letsgettechnical/image:dev
#A workflow is for testing
tests:
jest-test:
runs-on: ubuntu-latest

strategy:
Expand All @@ -48,3 +48,27 @@ jobs:
run: pnpm install
- name: tests
run: pnpm test
#Playwright Testing
playwright-test:
timeout-minutes: 60000
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30


8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

*storybook.log
#playwright
/blob-report/
/playwright/.cache/

*storybook.log
/blob-report/
/playwright/.cache/
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,26 @@ Run Storybook in the project root
```
npm run storybook
```

## React Testing Library (RTL) && Jest

Run RTL && Jest in the project root

```
pnpm test
```

## Playwright Testing


Run all Playwright tests

```
pnpm exec playwright test
```

Run single Playwright tests

```
pnpm exec playwright test (name of file)
```
3 changes: 3 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const config: Config = {
// Add more setup options before each test is run
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
preset: "ts-jest",
testPathIgnorePatterns: [
"<rootDir>/tests/playwright-tests/",
]
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
Expand Down
111 changes: 56 additions & 55 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
{
"private": true,
"version": "0.1.0",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "jest --passWithNoTests",
"test:watch": "jest --watchAll --passWithNoTests",
"storybook-docs": "storybook dev --docs",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@radix-ui/react-slot": "^1.0.2",
"@supabase/ssr": "latest",
"@supabase/supabase-js": "latest",
"autoprefixer": "10.4.15",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"geist": "^1.2.2",
"lucide-react": "^0.312.0",
"next": "latest",
"postcss": "8.4.29",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwind-merge": "^2.2.2",
"tailwindcss": "3.3.3",
"tailwindcss-animate": "^1.0.7",
"typescript": "5.1.3"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.2.25",
"@storybook/addon-essentials": "^8.0.4",
"@storybook/addon-interactions": "^8.0.4",
"@storybook/addon-links": "^8.0.4",
"@storybook/addon-onboarding": "^8.0.4",
"@storybook/blocks": "^8.0.4",
"@storybook/nextjs": "^8.0.4",
"@storybook/react": "^8.0.4",
"@storybook/test": "^8.0.4",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.2",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.12",
"@types/node": "20.3.1",
"@types/react": "18.2.8",
"@types/react-dom": "18.2.5",
"encoding": "^0.1.13",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"storybook": "^8.0.4",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "5.1.3"
}
"private": true,
"version": "0.1.0",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "jest --passWithNoTests",
"test:watch": "jest --watchAll --passWithNoTests",
"storybook-docs": "storybook dev --docs",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@radix-ui/react-slot": "^1.0.2",
"@supabase/ssr": "latest",
"@supabase/supabase-js": "latest",
"autoprefixer": "10.4.15",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"geist": "^1.2.2",
"lucide-react": "^0.312.0",
"next": "latest",
"postcss": "8.4.29",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwind-merge": "^2.2.2",
"tailwindcss": "3.3.3",
"tailwindcss-animate": "^1.0.7",
"typescript": "5.1.3"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.2.25",
"@playwright/test": "^1.42.1",
"@storybook/addon-essentials": "^8.0.4",
"@storybook/addon-interactions": "^8.0.4",
"@storybook/addon-links": "^8.0.4",
"@storybook/addon-onboarding": "^8.0.4",
"@storybook/blocks": "^8.0.4",
"@storybook/nextjs": "^8.0.4",
"@storybook/react": "^8.0.4",
"@storybook/test": "^8.0.4",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.2",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.12",
"@types/node": "20.3.1",
"@types/react": "18.2.8",
"@types/react-dom": "18.2.5",
"encoding": "^0.1.13",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"storybook": "^8.0.4",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "5.1.3"
}
}
68 changes: 68 additions & 0 deletions playwright-report/index.html

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { defineConfig, devices } from '@playwright/test';

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

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './',
/* 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'] },
},
],

/* 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 ae0bdb5

Please sign in to comment.