Skip to content

Commit

Permalink
chore(widget): use @playwright/test instead of a less-well-supported …
Browse files Browse the repository at this point in the history
…test dependency (#183)
  • Loading branch information
andrewedstrom authored Nov 21, 2023
1 parent cce4e27 commit 069434d
Show file tree
Hide file tree
Showing 11 changed files with 627 additions and 314 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/widget-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
jobs:
nodejs_test:
runs-on: ubuntu-latest
container: mcr.microsoft.com/playwright:v1.39.0
container: mcr.microsoft.com/playwright:v1.40.0

timeout-minutes: 20

Expand Down
4 changes: 4 additions & 0 deletions packages/widget/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ dist-ssr
/playwright-report/
/blob-report/
/playwright/.cache/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
4 changes: 3 additions & 1 deletion packages/widget/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<p>
10.1101/273730
</p>
<docmaps-widget serverurl='https://web-nodejs.onrender.com' doi='10.1101/273730'></docmaps-widget>
<div id='root'>
<docmaps-widget serverurl='https://web-nodejs.onrender.com' doi='10.1101/273730'></docmaps-widget>
</div>
<br>
<br>
</body>
Expand Down
4 changes: 1 addition & 3 deletions packages/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
},
"devDependencies": {
"@docmaps/build-configs": "workspace:^",
"@playwright/experimental-ct-core": "^1.39.0",
"@playwright/test": "^1.39.0",
"@sand4rt/experimental-ct-web": "^1.39.0",
"@playwright/test": "^1.40.0",
"@types/d3": "^7.4.2",
"@types/d3-force": "^3.0.7",
"@types/d3-selection": "^3.0.8",
Expand Down
62 changes: 30 additions & 32 deletions packages/widget/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { defineConfig, devices } from '@sand4rt/experimental-ct-web'
import { widgetConfig } from './vite.config'
import { defineConfig, devices } from '@playwright/test';

const IS_CI = !!process.env.CI
const ALL_BROWSERS = !!process.env.ALL_BROWSERS
const IS_CI = !!process.env.CI;
const ALL_BROWSERS = !!process.env.ALL_BROWSERS;

// Locally we only run tests in Chromium
const localBrowsers = [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
]
];

// In CI, we run tests in all supported browsers
const all_browsers = [
Expand All @@ -28,58 +27,57 @@ const all_browsers = [
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
];

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

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
]
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

const url: string = 'http://localhost:5173';
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './test/integration',
/* 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: 30 * 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: IS_CI,

/* Retry on CI only */
retries: IS_CI ? 2 : 0,

/* Opt out of parallel tests on CI. */
workers: IS_CI ? 1 : undefined,

/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: IS_CI ? [['list'], ['html']] : 'list',

/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: url,

/* 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,

ctViteConfig: widgetConfig,
},

/* Configure projects for major browsers */
/* Which browsers to run the tests in */
projects: IS_CI || ALL_BROWSERS ? all_browsers : localBrowsers,
})

/* Run local dev server before starting the tests */
webServer: {
command: 'pnpm run dev',
url,
reuseExistingServer: !IS_CI,
},
});
12 changes: 0 additions & 12 deletions packages/widget/playwright/index.html

This file was deleted.

2 changes: 0 additions & 2 deletions packages/widget/playwright/index.ts

This file was deleted.

Loading

0 comments on commit 069434d

Please sign in to comment.