@blaze-cms/plugin-testing-e2e
v0.2.2
Published
Portable Playwright e2e framework and common spec library for Blaze ecommerce sites. Each repo keeps its own site-profile locator registry; this package supplies the locator engine, page objects, fixtures and shared tests.
Downloads
65
Maintainers
Keywords
Readme
@blaze-cms/plugin-testing-e2e
Portable Playwright e2e framework + common spec library for Blaze ecommerce sites.
The split: each repo owns its site profiles (locator registry, routes, feature flags, test data). This package owns everything generic — the locator engine, page objects, fixtures, global setup, base Playwright config, and the shared specs (smoke, search, auth, registration, cart, checkout, account, subscription signup). Specs gate themselves on profile feature flags and skip with a visible reason where a site lacks a capability.
Consuming suite layout (per repo)
tests-pw/e2e/
├── playwright.config.ts # blazeConfig(e2e) + repo overrides
├── global-setup.ts # createGlobalSetup(e2e)
├── .env / example.env
└── src/
├── profiles/ # THIS REPO'S locator registry (site profiles)
│ └── mysite.ts
├── e2e.ts # createBlazeE2E({ profiles, defaultSite })
└── tests/
├── smoke/smoke.spec.ts # registerSmokeSpecs(e2e) — one-liners
├── cart/cart.spec.ts # registerCartSpecs(e2e)
└── mysite/special.spec.ts # site-specific specs, using e2e.test + page objectsWiring
// src/e2e.ts
import { createBlazeE2E } from '@blaze-cms/plugin-testing-e2e';
import { mysiteProfile } from './profiles/mysite';
export const e2e = createBlazeE2E({ profiles: [mysiteProfile], defaultSite: 'mysite' });
export const { test, expect, requireFeature } = e2e;// playwright.config.ts
import { defineConfig } from '@playwright/test';
import { blazeConfig } from '@blaze-cms/plugin-testing-e2e';
import { e2e } from './src/e2e';
export default defineConfig(
blazeConfig(e2e, { globalSetup: require.resolve('./global-setup') }),
);// global-setup.ts
import { createGlobalSetup } from '@blaze-cms/plugin-testing-e2e';
import { e2e } from './src/e2e';
export default createGlobalSetup(e2e);// src/tests/smoke/smoke.spec.ts
import { registerSmokeSpecs } from '@blaze-cms/plugin-testing-e2e';
import { e2e } from '../../e2e';
registerSmokeSpecs(e2e);Profiles
A profile deep-merges overrides onto the shared .blaze-ecommerce-* baseline:
import { blazeBaseLocators, deepMerge, type SiteProfile } from '@blaze-cms/plugin-testing-e2e';
export const mysiteProfile: SiteProfile = {
key: 'mysite',
name: 'My Site',
defaultBaseUrl: 'https://frontend-mysite.stage.blazecms.app',
locators: deepMerge(blazeBaseLocators, {
auth: { email: { css: '#customer-email', first: true } },
}),
routes: { home: '/', login: '/login', basket: '/basket', checkout: '/checkout' },
features: { search: false, addToCart: true, flyoutBasket: true, cookieBanner: false,
registration: false, subscriptionSignup: false, checkout: 'none' },
data: { products: [{ path: '/p/thing', title: 'Thing' }], registrationValues: {} },
};Runtime knobs (same across all consumers): BLAZE_TEST_PLAYWRIGHT_SITE picks the
profile, BLAZE_TEST_PLAYWRIGHT_LOCATOR_OVERRIDES deep-merges a JSON file over the
active profile's locators (strings like "/accept/i" become regexes), plus the usual
BLAZE_TEST_PLAYWRIGHT_BASE_URL, BLAZE_TEST_HTTP_CREDENTIALS_*, BLAZE_X_CLIENT,
BLAZE_TEST_PLAYWRIGHT_USER_EMAIL/_PASSWORD, _WORKERS, _RETRIES,
_PLATFORM_COVERAGE, _ALLOW_REGISTRATION.
Local (pre-publish) consumption
Until this package is published, consumers can alias it in tsconfig.json —
Playwright resolves tsconfig paths and transpiles the TS source directly:
{ "compilerOptions": { "paths": {
"@blaze-cms/plugin-testing-e2e": ["../../../../../blaze-testing-tools/packages/e2e/src/index.ts"]
} } }Once published (yarn build emits dist/ CJS + typings), swap the alias for a
regular dependency: "@blaze-cms/plugin-testing-e2e": "^0.1.0".
