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
Copy file name to clipboardExpand all lines: README.md
+75Lines changed: 75 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ A comprehensive test utility package for Red Hat Developer Hub (RHDH) end-to-end
21
21
-[Environment Variables](#environment-variables)
22
22
-[Examples](#examples)
23
23
-[Development](#development)
24
+
-[Testing Local Changes in Consumer Projects](#testing-local-changes-in-consumer-projects)
24
25
25
26
## Overview
26
27
@@ -562,6 +563,80 @@ yarn build
562
563
|`yarn prettier:check`| Check code formatting |
563
564
|`yarn prettier:fix`| Auto-fix code formatting |
564
565
566
+
### Testing Local Changes in Consumer Projects
567
+
568
+
When developing features or fixes in`rhdh-e2e-test-utils`, you can test your local changes in a consumer project (e.g., a plugin's e2e-tests) before publishing.
569
+
570
+
#### 1. Build your local changes
571
+
572
+
```bash
573
+
cd /path/to/rhdh-e2e-test-utils
574
+
yarn build
575
+
```
576
+
577
+
#### 2. Update the consumer project's package.json
578
+
579
+
In your e2e-tests project, update the dependency to point to your local package using the `file:` protocol:
#### 3. Install dependencies in the consumer project
591
+
592
+
```bash
593
+
yarn install
594
+
```
595
+
596
+
#### 4. Run tests withNODE_PRESERVE_SYMLINKS
597
+
598
+
When running tests with a local symlinked package, you **must** set the `NODE_PRESERVE_SYMLINKS` environment variable:
599
+
600
+
```bash
601
+
NODE_PRESERVE_SYMLINKS=1 yarn test
602
+
NODE_PRESERVE_SYMLINKS=1 yarn test:headed
603
+
NODE_PRESERVE_SYMLINKS=1 yarn test:ui
604
+
```
605
+
606
+
>**Why is NODE_PRESERVE_SYMLINKS needed?**
607
+
>
608
+
> When using local packages via `file:` protocol, the package manager creates a symlink. Node.js follows symlinks by default and tries to resolve peer dependencies (like `@playwright/test`) from the original packagelocation. This causes duplicate Playwright instances which fails with:
609
+
>```
610
+
> Error: Requiring @playwright/test second time
611
+
> ```
612
+
> Setting `NODE_PRESERVE_SYMLINKS=1` tells Node.js to resolve dependencies from the symlink location (your project's `node_modules`) instead of the original package location.
613
+
614
+
#### 5. Rebuild after making changes
615
+
616
+
When you make further changes to `rhdh-e2e-test-utils`, rebuild before running tests:
617
+
618
+
```bash
619
+
cd /path/to/rhdh-e2e-test-utils
620
+
yarn build
621
+
```
622
+
623
+
Then run your tests again in the consumer project (no need to reinstall).
624
+
625
+
#### 6. Restore the published version
626
+
627
+
After testing, restore the published version in the consumer project's `package.json`:
628
+
629
+
```json
630
+
"rhdh-e2e-test-utils": "^1.0.0"
631
+
```
632
+
633
+
Then run:
634
+
```bash
635
+
yarn install
636
+
```
637
+
638
+
You can now run tests normally without `NODE_PRESERVE_SYMLINKS`.
0 commit comments