Skip to content

Commit ea7f8c2

Browse files
authored
Merge pull request #43 from ericblade/dev
More work on organizing tests with new playwright
2 parents 8a95c2d + fa196a3 commit ea7f8c2

3 files changed

Lines changed: 58 additions & 33 deletions

File tree

playwright.config.ts

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export default defineConfig({
1919
/* Retry on CI only */
2020
retries: process.env.CI ? 2 : 0,
2121
/* Opt out of parallel tests on CI. */
22-
workers: process.env.CI ? 1 : undefined,
22+
// workers: process.env.CI ? 1 : undefined,
23+
workers: undefined,
2324
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
2425
reporter: 'html',
2526
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
@@ -33,40 +34,56 @@ export default defineConfig({
3334

3435
/* Configure projects for major browsers */
3536
projects: [
37+
{
38+
name: 'base tests',
39+
testMatch: '**/base.spec.ts',
40+
},
41+
{
42+
name: 'mask tests',
43+
testMatch: '**/mask.spec.ts',
44+
dependencies: ['base tests'],
45+
},
3646
{
3747
name: 'chromium',
3848
use: { ...devices['Desktop Chrome'] },
49+
dependencies: ['base tests', 'mask tests'],
3950
},
4051

4152
{
4253
name: 'firefox',
4354
use: { ...devices['Desktop Firefox'] },
55+
dependencies: ['base tests', 'mask tests'],
4456
},
4557

4658
{
4759
name: 'webkit',
4860
use: { ...devices['Desktop Safari'] },
61+
dependencies: ['base tests', 'mask tests'],
4962
},
5063

5164
/* Test against mobile viewports. */
52-
// {
53-
// name: 'Mobile Chrome',
54-
// use: { ...devices['Pixel 5'] },
55-
// },
56-
// {
57-
// name: 'Mobile Safari',
58-
// use: { ...devices['iPhone 12'] },
59-
// },
65+
{
66+
name: 'Mobile Chrome',
67+
use: { ...devices['Pixel 5'] },
68+
dependencies: ['base tests', 'mask tests'],
69+
},
70+
{
71+
name: 'Mobile Safari',
72+
use: { ...devices['iPhone 12'] },
73+
dependencies: ['base tests', 'mask tests'],
74+
},
6075

6176
/* Test against branded browsers. */
62-
// {
63-
// name: 'Microsoft Edge',
64-
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
65-
// },
66-
// {
67-
// name: 'Google Chrome',
68-
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
69-
// },
77+
{
78+
name: 'Microsoft Edge',
79+
use: { ...devices['Desktop Edge'], channel: 'msedge' },
80+
dependencies: ['base tests', 'mask tests'],
81+
},
82+
{
83+
name: 'Google Chrome',
84+
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
85+
dependencies: ['base tests', 'mask tests'],
86+
},
7087
],
7188

7289
/* Run your local dev server before starting the tests */

tests/base.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { test, expect } from '@playwright/test';
2+
import * as path from 'path';
3+
4+
const projectDir = path.resolve(__dirname, '../');
5+
const filePath = path.join(projectDir, 'examples/index.html');
6+
const fileUrl = `file://${filePath}`;
7+
8+
test.describe('base tests', () => {
9+
test.beforeEach(async ({ page }) => {
10+
await page.goto(fileUrl);
11+
});
12+
13+
test('sanity startup', async ({ page }) => {
14+
const currencyInput = await page.locator('#currency-input');
15+
await expect(currencyInput).toHaveValue('$0.00 USD');
16+
});
17+
18+
test('undefined value results in correct 0 of input', async ({ page }) => {
19+
const nullInputTest = await page.locator('#null-input-test');
20+
await expect(nullInputTest).toHaveValue('$0.00 USD');
21+
});
22+
});
23+
24+
// TODO: add tests for each of the possible parameters
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,6 @@ const projectDir = path.resolve(__dirname, '../');
55
const filePath = path.join(projectDir, 'examples/index.html');
66
const fileUrl = `file://${filePath}`;
77

8-
test.describe('test', () => {
9-
test.beforeEach(async ({ page }) => {
10-
await page.goto(fileUrl);
11-
});
12-
13-
test('sanity startup', async ({ page }) => {
14-
const currencyInput = await page.locator('#currency-input');
15-
await expect(currencyInput).toHaveValue('$0.00 USD');
16-
});
17-
18-
test('undefined value results in correct 0 of input', async ({ page }) => {
19-
const nullInputTest = await page.locator('#null-input-test');
20-
await expect(nullInputTest).toHaveValue('$0.00 USD');
21-
});
22-
});
23-
248
test.describe('input caret selection', () => {
259
const suffix = ' USD';
2610
const prefix = '$';

0 commit comments

Comments
 (0)