Skip to content

Commit 7ae7082

Browse files
committed
chore: add TypeScript strict checking command
1 parent 466edec commit 7ae7082

File tree

10 files changed

+54
-50
lines changed

10 files changed

+54
-50
lines changed

.husky/pre-commit

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
npm run lint
1+
npm run lint
2+
npm run format:check
3+
npm run tsc:check

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"ms-playwright.playwright",
44
"eamodio.gitlens",
55
"esbenp.prettier-vscode",
6-
"dbaeumer.vscode-eslint"
6+
"dbaeumer.vscode-eslint",
7+
"streetsidesoftware.code-spell-checker"
78
]
89
}

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"editor.formatOnSave": true,
33
"editor.defaultFormatter": "esbenp.prettier-vscode",
44
"editor.codeActionsOnSave": {
5-
"source.organizeImports": true
6-
}
5+
"source.organizeImports": "explicit"
6+
},
7+
"cSpell.words": ["trivago", "tseslint"]
78
}

README.md

Whitespace-only changes.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
"main": "index.js",
66
"scripts": {
77
"format": "npx prettier --write .",
8-
"lint": "npx eslint . --max-warnings 0"
8+
"format:check": "npx prettier . --check \"!**.ts\"",
9+
"lint": "npx eslint . --max-warnings 0",
10+
"tsc:check": "npx tsc --noEmit --pretty --strict",
11+
"test": "npx playwright test",
12+
"test:headed": "npx playwright test -- --headed",
13+
"test:ui": "npm run test -- --ui",
14+
"show-report": "npx playwright show-report"
915
},
1016
"keywords": [],
1117
"author": "",

playwright.config.ts

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,24 @@ import { defineConfig, devices } from '@playwright/test';
22

33
export default defineConfig({
44
testDir: './tests',
5+
timeout: 60_000,
6+
expect: {
7+
timeout: 10_000,
8+
},
59
fullyParallel: true,
10+
retries: 0,
11+
workers: undefined,
612
reporter: 'html',
713
use: {
8-
/* Base URL to use in actions like `await page.goto('/')`. */
9-
// baseURL: 'http://127.0.0.1:3000',
10-
11-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
12-
trace: 'on-first-retry',
14+
actionTimeout: 0,
15+
trace: 'retain-on-failure',
16+
video: 'retain-on-failure',
17+
screenshot: 'only-on-failure',
1318
},
14-
15-
/* Configure projects for major browsers */
1619
projects: [
1720
{
1821
name: 'chromium',
1922
use: { ...devices['Desktop Chrome'] },
2023
},
21-
22-
{
23-
name: 'firefox',
24-
use: { ...devices['Desktop Firefox'] },
25-
},
26-
27-
{
28-
name: 'webkit',
29-
use: { ...devices['Desktop Safari'] },
30-
},
31-
32-
/* Test against mobile viewports. */
33-
// {
34-
// name: 'Mobile Chrome',
35-
// use: { ...devices['Pixel 5'] },
36-
// },
37-
// {
38-
// name: 'Mobile Safari',
39-
// use: { ...devices['iPhone 12'] },
40-
// },
41-
42-
/* Test against branded browsers. */
43-
// {
44-
// name: 'Microsoft Edge',
45-
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
46-
// },
47-
// {
48-
// name: 'Google Chrome',
49-
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
50-
// },
5124
],
52-
53-
/* Run your local dev server before starting the tests */
54-
// webServer: {
55-
// command: 'npm run start',
56-
// url: 'http://127.0.0.1:3000',
57-
// reuseExistingServer: !process.env.CI,
58-
// },
5925
});

tests-examples/demo-todo-app.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ async function checkNumberOfCompletedTodosInLocalStorage(
472472
page: Page,
473473
expected: number,
474474
) {
475-
console.log('test');
476475
return await page.waitForFunction((e) => {
477476
return (
478477
JSON.parse(localStorage['react-todos']).filter(

tests/example.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { PlaywrightPage } from './playwright.page';
12
import { expect, test } from '@playwright/test';
23

34
test('has title', async ({ page }) => {
@@ -17,3 +18,12 @@ test('get started link', async ({ page }) => {
1718
page.getByRole('heading', { name: 'Installation' }),
1819
).toBeVisible();
1920
});
21+
22+
test('get started link pom', async ({ page }) => {
23+
const playwrightPage = new PlaywrightPage(page);
24+
await playwrightPage.goto();
25+
await playwrightPage.button.click();
26+
await expect(
27+
page.getByRole('heading', { name: 'Installation' }),
28+
).toBeVisible();
29+
});

tests/playwright.page.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Page } from '@playwright/test';
2+
3+
export class PlaywrightPage {
4+
button = page.getByRole('link', { name: 'Get started' });
5+
6+
constructor(private page: Page) {}
7+
8+
async goto(): Promise<void> {
9+
await this.page.goto('https://playwright.dev/');
10+
}
11+
}

tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"strict": true,
5+
"module": "CommonJS",
6+
"sourceMap": true
7+
}
8+
}

0 commit comments

Comments
 (0)