You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -489,6 +490,14 @@ Use web-first assertions, like `await expect(checkboxLocator).not.toBeChecked()`
489
490
490
491
## Best Practices
491
492
493
+
### Avoid Frontend Code in E2E Tests
494
+
495
+
It is crucial to avoid importing frontend code into E2E tests, especially if it transitively imports stylesheets. This can lead to unexpected issues with the test runner and slow down test execution.
496
+
497
+
For example, importing `defaultProps` from a component file like `ButtonNative.tsx` into a test file like `Button.spec.ts` is an anti-pattern. The component file likely imports SCSS or CSS files, which should not be part of the test environment.
498
+
499
+
Instead, if you need to share data between your component and your tests, define it in a separate file that can be imported safely by both.
500
+
492
501
### Skipping tests
493
502
494
503
#### Skipping For coverage
@@ -545,7 +554,7 @@ Components that support layout properties (like `labelPosition`, `direction`, po
545
554
546
555
#### Best Practices for Layout Testing
547
556
548
-
-**Import getBounds**: Import from `"../../testing/component-test-helpers"`
557
+
-**Import getBounds**: Import from `"../../testing/component-test-helpers"`
549
558
-**Use descriptive coordinates**: Destructure specific properties like `{ left, right, top, bottom }`
550
559
-**Test both directions**: Include RTL tests when direction affects layout
551
560
-**Verify invalid values**: Test graceful handling of invalid layout properties
@@ -555,7 +564,10 @@ Components that support layout properties (like `labelPosition`, `direction`, po
555
564
Use `getBounds()` to get element coordinates and verify relative positioning:
556
565
557
566
```typescript
558
-
test("ComponentName appears at the correct side of ComponentName2", async ({ initTestBed, page }) => {
567
+
test("ComponentName appears at the correct side of ComponentName2", async ({
568
+
initTestBed,
569
+
page,
570
+
}) => {
559
571
awaitinitTestBed(`
560
572
<Fragment>
561
573
<ComponentName testId="comp1" />
@@ -614,9 +626,7 @@ test("all adornments appear in the right place", async ({ initTestBed, page }) =
Copy file name to clipboardExpand all lines: xmlui/dev-docs/build-system.md
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -428,25 +428,24 @@ src/
428
428
```
429
429
dist/
430
430
├── lib/ # Library build
431
-
│ ├── xmlui.mjs
431
+
│ ├── xmlui.js
432
432
│ ├── xmlui.d.ts
433
-
│ ├── xmlui-parser.mjs
434
-
│ ├── language-server.mjs
433
+
│ ├── xmlui-parser.js
434
+
│ ├── language-server.js
435
435
│ └── scss/ # SCSS source files
436
436
├── standalone/ # Standalone build
437
437
│ └── xmlui-standalone.umd.js
438
438
├── metadata/ # Metadata build
439
439
│ └── xmlui-metadata.js
440
-
└── scripts/
441
-
└── bin/
442
-
└── vite-xmlui-plugin.js
440
+
└── bin/
441
+
└── index.js
443
442
```
444
443
445
444
### Bin Scripts
446
445
447
446
```
448
447
bin/
449
-
├── bootstrap.js # CLI entry (ts-node setup)
448
+
├── bootstrap.js # CLI entry for development (uses tsx)
450
449
├── index.ts # Command router
451
450
├── build.ts # Build implementation
452
451
├── build-lib.ts # Library build
@@ -726,7 +725,7 @@ This table summarizes when to run builds across different contexts:
726
725
|**xmlui/**| Building standalone |`npm run build:xmlui-standalone`|`vite build --mode standalone`| For CDN/buildless | Creates self-contained UMD bundle for `<script>` tag usage; framework builds itself with Vite directly |
727
726
|**xmlui/**| Generating metadata |`npm run build:xmlui-metadata`|`vite build --mode metadata`| After component changes, before doc generation | Extracts component metadata into `xmlui-metadata.js` for documentation generation and language server autocomplete. This is the source of truth for component APIs, props, and descriptions. Framework uses Vite directly. |
728
727
|**xmlui/**| Full doc generation |`npm run generate-all-docs`| Node scripts (not CLI) | After metadata changes | Runs three scripts: (1) `build:xmlui-metadata` - extracts metadata, (2) `generate-docs` - creates component .md files from metadata, (3) `generate-docs-summaries` - creates overview/summary files. This is the complete pipeline from source code → documentation |
729
-
|**xmlui/**| Compile bin scripts |`npm run build:bin`|`tsc -p tsconfig.bin.json`| After changes to bin/\*.ts files | Compiles TypeScript bin scripts (CLI tools) to JavaScript using TypeScript directly; needed when modifying build system or CLI commands|
728
+
|**xmlui/**| Compile bin scripts |`npm run build:bin`|`tsdown`| After changes to bin/\*.ts files | Compiles TypeScript bin scripts (CLI tools) to JavaScript using tsdown (see tsdown.config.ts); needed when modifying build system or CLI commands |
730
729
|**extension/**| Development |`npm start`|`xmlui start`| Keep running during dev | Runs dev server with HMR for demo app; use with build-watch in separate terminal |
731
730
|**extension/**| Watch mode build |`npm run build-watch`|`xmlui build-lib --watch`| Keep running during dev | Continuously rebuilds extension library on changes; pair with `npm start` for rapid iteration |
732
731
|**extension/**| Building for publish |`npm run build:extension`|`xmlui build-lib`| Before npm publish | Creates distributable library bundle (.mjs, .js, .d.ts, CSS) for npm package |
@@ -360,8 +378,8 @@ This internally runs in order:
360
378
```bash
361
379
# 1. Build CLI tools
362
380
npm run build:bin
363
-
# Compiles TypeScript in bin/ folder using tsconfig.bin.json
364
-
# Output: bin/*.js files
381
+
# Compiles TypeScript in bin/ folder using tsdown (see tsdown.config.ts)
382
+
# Output: dist/bin/
365
383
366
384
# 2. Build library for npm
367
385
npm run build:xmlui
@@ -405,11 +423,16 @@ The `clean-package` tool transforms package.json during publish:
405
423
{
406
424
"main": "./dist/lib/xmlui.js",
407
425
"bin": {
408
-
"xmlui": "dist/scripts/bin/bootstrap.js"
426
+
"xmlui": "dist/bin/index.js"
409
427
}
410
428
}
411
429
```
412
430
431
+
> **Note on CLI Development:**
432
+
> In the development environment, the `xmlui` command points to `bin/bootstrap.js`. This file uses `tsx` to execute the CLI's TypeScript source (`bin/index.ts`) on-the-fly. This allows for rapid development of the CLI without requiring a separate build step for every change.
433
+
>
434
+
> For production, `clean-package` replaces the `bin` entry to point to the compiled `dist/bin/index.js`, ensuring the published package does not rely on `tsx`.
0 commit comments