Skip to content

Commit

Permalink
attempt on playright
Browse files Browse the repository at this point in the history
  • Loading branch information
Jagoda11 committed Dec 23, 2024
1 parent 720cacc commit 7b02f0d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 20 deletions.
18 changes: 18 additions & 0 deletions e2e-tests /dashboard.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from '@playwright/test'

test.describe('GitHub Insights Dashboard', () => {
test('should display the dashboard title', async ({ page }) => {
await page.goto('/')
const title = await page.title()
expect(title).toBe('GitHub Insights Dashboard')
})

test('should navigate to the Commit List page', async ({ page }) => {
await page.goto('/')
const commitListLink = page.getByRole('link', { name: 'Commit List' })
await commitListLink.click()
await expect(page).toHaveURL('/commits') // Adjust based on your routing
const heading = await page.getByRole('heading', { name: 'Commit List' }) // Replace with actual heading
await expect(heading).toBeVisible()
})
})
3 changes: 2 additions & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/setupTests.ts'],
testMatch: ['**/*.test.ts', '**/*.test.tsx'],
testMatch: ['**/*.test.tsx'],
moduleDirectories: ['node_modules', 'src'],
testPathIgnorePatterns: [
'/node_modules/',
'/playwright-tests/',
'/e2e-tests/',
'/cypress-tests/',
'/dist/',
],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"start": "echo '🚀 Starting the app...' && webpack serve --config webpack.config.mjs && echo '🌟✨ App is up and running! Visit http://localhost:3002/github-insights-dashboard/ ✨'",
"build": "echo '🔨 Building the app...' && webpack --config webpack.config.mjs && echo '🏗️✨ Build completed! Your app is ready! ✨'",
"test": "echo '🧪 Running tests...' && jest --config jest.config.cjs --coverage",
"test:e2e": "echo '🎭 Running Playwright E2E tests...' && npx playwright test",
"format": "echo '🖋️ Formatting code... Please wait.' && prettier --write . && echo '✅ Your code is formatted!'",
"lint": "echo '🧹 Linting code... Please wait.' && eslint -c eslint.config.js . && echo '✅ Linting complete. Your code is clean!'",
"lint-fix": "echo '🔧 Linting and fixing issues...' && eslint --fix . && prettier --write .",
Expand Down
18 changes: 18 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from '@playwright/test'
import { fileURLToPath } from 'url'
import { resolve, dirname } from 'path'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

export default defineConfig({
testDir: './e2e-tests', // Adjusted to point to the root's e2e-tests folder
timeout: 30000, // Timeout for each test
retries: 2, // Retry failed tests
use: {
headless: true, // Run tests in headless mode
baseURL: `file://${resolve(__dirname, './dist/github-insights-dashboard/index.html')}`, // Path to your built app
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
},
})
15 changes: 0 additions & 15 deletions src/App.test.tsx

This file was deleted.

5 changes: 1 addition & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import CommitList from './components/CommitList'
const App: React.FC = () => {
const token = localStorage.getItem('githubToken')

const isLocal = window.location.origin.includes('localhost')
const basename = isLocal ? '/' : '/github-insights-dashboard'

return (
<Router basename={basename}>
<Router basename="/github-insights-dashboard">
<div className="p-4">
<nav className="mb-4">
<Link to="/" className="mr-4">
Expand Down

0 comments on commit 7b02f0d

Please sign in to comment.