Testing
E2E testing is optional. Enable it when you have a stable target URL and need repeatable smoke coverage across Samsung markets.
Skip E2E during early prototyping. You can add it later by copying the generated files from a fresh E2E-enabled project.
What gets generated
When you answer yes to the E2E prompt, the scaffold adds:
e2e/
config.js
helpers.js
smoke.spec.js
playwright.config.jsIt also adds:
{
"scripts": {
"test:e2e": "pnpm build && playwright test"
}
}Setup
If the CLI generated E2E files, it also runs Playwright browser setup during project creation. If you clone or restore an E2E-enabled project later, install the browser manually:
pnpm playwright install chromiumRun tests with:
pnpm test:e2eThis command builds first, then runs Playwright. Fix lint or build errors before debugging the browser test.
Generated files
| File | Purpose |
|---|---|
playwright.config.js | Uses ./e2e, Desktop Chrome, HTML reporter, failure screenshots, and CI retries. |
e2e/config.js | Stores baseUrl, bundlePath, markets, and URL construction. |
e2e/helpers.js | Loads the IIFE bundle, prepares the page, injects the bundle, and captures screenshots. |
e2e/smoke.spec.js | Runs one smoke test per configured market. |
Product-card helpers also mock the Samsung product API before injection. Minimal helpers keep setup smaller because no product API data is required.
Smoke test flow
The generated smoke test does this for each configured market:
- Build
dist/v1/v1.jsthroughpnpm test:e2e. - Resolve the market URL from
e2e/config.js. - Navigate to the page.
- Inject or find the target element.
- Add the IIFE bundle to the page.
- Wait for the selector-derived experiment container.
- Attach screenshots or page metadata to the Playwright report.
Markets
Market groups expand into one test iteration per country. For example, SEBN runs Belgium Dutch, Belgium French, and Netherlands.
Use e2e/config.js when you need to adjust market coverage after scaffolding:
export const urlsConfig = {
baseUrl: 'https://www.samsung.com',
bundlePath: 'dist/v1/v1.js',
markets: [{ code: 'UK', urlPath: 'uk', name: 'United Kingdom' }],
};Custom market codes fall back to lowercase URL paths in the scaffolder.
Add assertions
Start from the smoke test. Add assertions after setup finishes:
test(`cta renders - ${market.name}`, async ({ page }, testInfo) => {
await setupPage(page, market, testInfo);
const container = page.locator(experimentContainer);
await expect(container.getByRole('link', { name: /shop/i })).toBeVisible();
});Keep assertions focused on experiment behavior. Avoid testing Samsung page features that the experiment does not own.
Next
- Markets Reference lists available market groups.
- Framework API explains the runtime helpers used by generated experiments.