Skip to content

Commit

Permalink
test: update tests to use consistent port number and ignore unused a1…
Browse files Browse the repository at this point in the history
…1y rules
  • Loading branch information
nerdyman committed Nov 16, 2023
1 parent 2f54fb9 commit 540de8b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import react from '@vitejs/plugin-react';
export default defineConfig({
server: {
host: '0.0.0.0',
port: 3000,
port: !isNaN(Number(process.env.PORT)) ? Number(process.env.PORT) : 3000,
},
clearScreen: false,
plugins: [react()],
Expand Down
18 changes: 13 additions & 5 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
/* eslint no-console: 0 */
import { devices } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';

const IS_CI = !!process.env.CI;
const PORT = !isNaN(Number(process.env.PORT)) ? Number(process.env.PORT) : 3000;

process.env.PORT = String(PORT);

console.info('[playwright.config]', { IS_CI, PORT });

const config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
forbidOnly: IS_CI,
retries: IS_CI ? 2 : 0,
testDir: './test',
outputDir: './test/results',
reporter: 'list',
webServer: {
command: 'pnpm run build && pnpm run start --filter="./example"',
reuseExistingServer: !process.env.CI,
url: 'http://localhost:3000',
command: 'pnpm run build && pnpm --filter "react-image-turntable-example" run start',
reuseExistingServer: !IS_CI,
url: `http://localhost:${PORT}`,
env: {
NODE_ENV: 'test',
USE_BABEL_PLUGIN_ISTANBUL: '1',
Expand Down
15 changes: 11 additions & 4 deletions test/ExampleRepo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import type { Page } from '@playwright/test';

import { test, expect } from './baseFixtures';
// import { test, expect } from './baseFixtures';
import { test, expect } from '@playwright/test';
import { checkA11y, configureAxe, injectAxe } from 'axe-playwright';

test.describe('Example Repo', () => {
const getComponentRoot = (page: Page) => page.locator('[role="slider"]');
const getComponentRoot = (page: Page) => page.getByRole('slider');

test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:3000/?debug');
await page.goto(`http://localhost:${process.env.PORT}/?debug`);
await injectAxe(page);

configureAxe(page, {
checks: [{ id: 'page-has-heading-one', enabled: false }],
checks: [
{ id: 'page-has-heading-one', enabled: false },
{ id: 'meta-viewport', enabled: false },
{ id: 'region', enabled: false },
],
});
});

test.afterEach(async ({ page }) => {
await checkA11y(page);
});

Expand Down

0 comments on commit 540de8b

Please sign in to comment.