Skip to content

Commit

Permalink
chore(request-nanostores): Test documented behavior WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryuni committed Sep 18, 2024
1 parent 8169551 commit 0b7026d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 19 deletions.
13 changes: 6 additions & 7 deletions packages/request-nanostores/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,24 @@
"build": "tsup",
"dev": "tsup --watch",
"prepublish": "pnpm run build",
"test": "echo 'No tests for now :('",
"test:run": "vitest run --coverage",
"test:dev": "vitest --coverage.enabled=true"
"test": "echo 'Run test:e2e'",
"test:e2e": "playwright test",
"test:e2e:report": "playwright show-report"
},
"dependencies": {
"@inox-tools/request-state": "workspace:^",
"@inox-tools/utils": "workspace:^",
"astro-integration-kit": "catalog:"
},
"devDependencies": {
"@inox-tools/astro-tests": "workspace:",
"@playwright/test": "catalog:",
"@types/node": "catalog:",
"@vitest/coverage-v8": "catalog:",
"@vitest/ui": "catalog:",
"astro": "catalog:",
"jest-extended": "catalog:",
"tsup": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
"vitest": "catalog:"
"vite": "catalog:"
},
"peerDependencies": {
"astro": "catalog:lax",
Expand Down
78 changes: 78 additions & 0 deletions packages/request-nanostores/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import {
defineConfig,
devices,
type Project,
type PlaywrightWorkerOptions,
} from '@playwright/test';

type Proj = Project<{}, PlaywrightWorkerOptions>;

const browserOptions: Record<string, Proj['use']> = {
chromium: {
...devices['Desktop Chrome'],
launchOptions: {
executablePath: process.env.PLAYWRIGHT_CHROME_BIN,
},
},
firefox: {
...devices['Desktop Firefox'],
launchOptions: {
executablePath: process.env.PLAYWRIGHT_FIREFOX_BIN,
},
},
webkit: {
...devices['Desktop Safari'],
launchOptions: {
executablePath: process.env.PLAYWRIGHT_WEBKIT_BIN,
},
},
};

const browsers: Record<string, Proj> = Object.fromEntries(
Object.entries(browserOptions).map(([key, value]) => [
key,
{
name: key,
use: value,
},
])
);

const projects: Proj[] = [browsers.chromium];

if (process.env.CI) {
projects.push(browsers.firefox, browsers.webkit);
} else {
if (process.env.PLAYWRIGHT_FIREFOX_RUN) {
projects.push(browsers.firefox);
}

if (process.env.PLAYWRIGHT_WEBKIT_RUN) {
projects.push(browsers.webkit);
}
}

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : 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. */
use: {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: projects,
});
1 change: 0 additions & 1 deletion packages/request-nanostores/tests/env.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/request-nanostores/tests/vitest.setup.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/request-nanostores/vitest.config.mjs

This file was deleted.

0 comments on commit 0b7026d

Please sign in to comment.