Skip to content

Commit

Permalink
Merge pull request #43 from ericblade/dev
Browse files Browse the repository at this point in the history
More work on organizing tests with new playwright
  • Loading branch information
ericblade authored Jul 22, 2024
2 parents 8a95c2d + fa196a3 commit ea7f8c2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 33 deletions.
51 changes: 34 additions & 17 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export default defineConfig({
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
// workers: process.env.CI ? 1 : undefined,
workers: 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. */
Expand All @@ -33,40 +34,56 @@ export default defineConfig({

/* Configure projects for major browsers */
projects: [
{
name: 'base tests',
testMatch: '**/base.spec.ts',
},
{
name: 'mask tests',
testMatch: '**/mask.spec.ts',
dependencies: ['base tests'],
},
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
dependencies: ['base tests', 'mask tests'],
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
dependencies: ['base tests', 'mask tests'],
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
dependencies: ['base tests', 'mask tests'],
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
dependencies: ['base tests', 'mask tests'],
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
dependencies: ['base tests', 'mask tests'],
},

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
{
name: 'Microsoft Edge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
dependencies: ['base tests', 'mask tests'],
},
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
dependencies: ['base tests', 'mask tests'],
},
],

/* Run your local dev server before starting the tests */
Expand Down
24 changes: 24 additions & 0 deletions tests/base.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { test, expect } from '@playwright/test';
import * as path from 'path';

const projectDir = path.resolve(__dirname, '../');
const filePath = path.join(projectDir, 'examples/index.html');
const fileUrl = `file://${filePath}`;

test.describe('base tests', () => {
test.beforeEach(async ({ page }) => {
await page.goto(fileUrl);
});

test('sanity startup', async ({ page }) => {
const currencyInput = await page.locator('#currency-input');
await expect(currencyInput).toHaveValue('$0.00 USD');
});

test('undefined value results in correct 0 of input', async ({ page }) => {
const nullInputTest = await page.locator('#null-input-test');
await expect(nullInputTest).toHaveValue('$0.00 USD');
});
});

// TODO: add tests for each of the possible parameters
16 changes: 0 additions & 16 deletions tests/test.spec.ts → tests/caret-selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,6 @@ const projectDir = path.resolve(__dirname, '../');
const filePath = path.join(projectDir, 'examples/index.html');
const fileUrl = `file://${filePath}`;

test.describe('test', () => {
test.beforeEach(async ({ page }) => {
await page.goto(fileUrl);
});

test('sanity startup', async ({ page }) => {
const currencyInput = await page.locator('#currency-input');
await expect(currencyInput).toHaveValue('$0.00 USD');
});

test('undefined value results in correct 0 of input', async ({ page }) => {
const nullInputTest = await page.locator('#null-input-test');
await expect(nullInputTest).toHaveValue('$0.00 USD');
});
});

test.describe('input caret selection', () => {
const suffix = ' USD';
const prefix = '$';
Expand Down

0 comments on commit ea7f8c2

Please sign in to comment.