Skip to content

Commit

Permalink
feat(playwright-ct): add playwright-ct config
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackshelton committed Feb 5, 2024
1 parent 8b98009 commit 8bb33d5
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 13 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ testem.log
# System Files
.DS_Store
Thumbs.db
.nx/cache
.nx/cache
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
10 changes: 10 additions & 0 deletions apps/qwik-app/src/components/demo-test/demo-test.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// eslint-disable-next-line @nx/enforce-module-boundaries
import { test, expect } from '../../../../../dist/packages/playwright-ct-qwik/';
import { DemoTest } from './demo-test';

test.use({ viewport: { width: 500, height: 500 } });

test('should work', async ({ mount }) => {
const component = await mount(<DemoTest />);
await expect(component).toContainText('Hello from playwright-ct-qwik');
});
6 changes: 6 additions & 0 deletions apps/qwik-app/src/components/demo-test/demo-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { component$ } from "@builder.io/qwik";

export const DemoTest = component$(() => {
return (<div>Hello from playwright-ct-qwik</div>)
})

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"build": "nx build playwright-ct-qwik",
"commit": "git-cz",
"format:fix": "pretty-quick --staged",
"prepare": "husky install"
"prepare": "husky install",
"test-ct": "playwright test -c playwright-ct.config.ts"
},
"devDependencies": {
"@builder.io/qwik": "1.4.2",
Expand All @@ -19,11 +20,11 @@
"@commitlint/config-angular": "^17.6.5",
"@commitlint/config-conventional": "^17.6.5",
"@jscutlery/semver": "^3.0.0",
"@nx/workspace": "17.2.8",
"@nx/vite": "17.2.8",
"@nx/js": "17.2.8",
"@nx/eslint-plugin": "17.2.8",
"@nx/eslint": "17.2.8",
"@nx/eslint-plugin": "17.2.8",
"@nx/js": "17.2.8",
"@nx/vite": "17.2.8",
"@nx/workspace": "17.2.8",
"@playwright/experimental-ct-core": "1.42.0-alpha-jan-18-2024",
"@playwright/test": "1.41.1",
"@types/eslint": "8.56.2",
Expand Down Expand Up @@ -62,6 +63,5 @@
"qwik",
"playwright",
"component testing"
],
"dependencies": {}
]
}
11 changes: 6 additions & 5 deletions packages/playwright-ct-qwik/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
"allowSyntheticDefaultImports": true,
"noFallthroughCasesInSwitch": true,
"jsxImportSource": "@builder.io/qwik",
"jsx": "react-jsx"
"jsx": "react-jsx",
"esModuleInterop": true,
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
"path": "./tsconfig.lib.json",
},
{
"path": "./tsconfig.definition.json"
}
]
"path": "./tsconfig.definition.json",
},
],
}
48 changes: 48 additions & 0 deletions playwright-ct.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

// @ts-ignore
import { defineConfig, devices } from './dist/packages/playwright-ct-qwik'

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './',
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
snapshotDir: './__snapshots__',
/* Maximum time one test can run for. */
timeout: 10 * 1000,
/* 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: {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',

/* Port to use for Playwright component endpoint. */
ctPort: 3100,
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
});
12 changes: 12 additions & 0 deletions playwright/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Testing Page</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./index.tsx"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions playwright/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Import styles, initialize component theme here.
// import '../src/common.css';
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"esModuleInterop": true,
"paths": {
"playwright-ct-qwik": ["packages/playwright-ct-qwik/src/index.ts"]
}
Expand Down

0 comments on commit 8bb33d5

Please sign in to comment.