Skip to content

Commit

Permalink
test: playwright boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency committed Nov 21, 2024
1 parent dbc6ca0 commit a058424
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ yarn-error.log*
next-env.d.ts

.idea/
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
Binary file modified bun.lockb
Binary file not shown.
6 changes: 6 additions & 0 deletions e2e/landing.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/Alberto - Blockchain App/);
});
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
},
"dependencies": {
"@chain-registry/assets": "^1.64.83",
"@liftedinit/manifestjs": "0.0.1-alpha.19",
"@cosmjs/cosmwasm-stargate": "0.32.4",
"@cosmjs/stargate": "npm:@liftedinit/[email protected]",
"@cosmos-kit/react": "2.18.0",
Expand All @@ -40,6 +39,7 @@
"@headlessui/react": "^1.7.18",
"@heroicons/react": "^2.1.5",
"@interchain-ui/react": "1.23.31",
"@liftedinit/manifestjs": "0.0.1-alpha.19",
"@react-three/drei": "^9.114.0",
"@react-three/fiber": "^8.17.8",
"@tanstack/react-query": "^5.55.0",
Expand Down Expand Up @@ -76,6 +76,7 @@
},
"devDependencies": {
"@happy-dom/global-registrator": "^15.7.3",
"@playwright/test": "^1.49.0",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/typography": "^0.5.8",
Expand All @@ -85,13 +86,14 @@
"@types/bad-words": "^3.0.3",
"@types/crypto-js": "^4.2.2",
"@types/identicon.js": "^2.3.4",
"@types/node": "^22.9.1",
"@types/react": "18.3.5",
"@types/react-dom": "18.3.0",
"@types/react-scroll": "^1.8.10",
"@types/three": "^0.169.0",
"bun-types": "^1.1.29",
"codecov": "^3.8.3",
"eslint": "8.56.0",
"eslint": "8.57.1",
"eslint-config-next": "13.0.5",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
Expand Down
83 changes: 83 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
/* 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 Chrome (landscape)',
use: { ...devices['Pixel 5 landscape'] },
},
// {
// 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: 'bun run start',
url: 'http://127.0.0.1:3000',
reuseExistingServer: !process.env.CI,
},
});

0 comments on commit a058424

Please sign in to comment.