Skip to content

Commit fc8cb94

Browse files
Fix config file resolution for published package (#6)
* Fix config file paths and build to reference dist directory * Fix config file paths and build to reference dist directory
1 parent 0797d64 commit fc8cb94

File tree

3 files changed

+81
-9
lines changed

3 files changed

+81
-9
lines changed

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ A comprehensive test utility package for Red Hat Developer Hub (RHDH) end-to-end
2121
- [Environment Variables](#environment-variables)
2222
- [Examples](#examples)
2323
- [Development](#development)
24+
- [Testing Local Changes in Consumer Projects](#testing-local-changes-in-consumer-projects)
2425

2526
## Overview
2627

@@ -562,6 +563,80 @@ yarn build
562563
| `yarn prettier:check` | Check code formatting |
563564
| `yarn prettier:fix` | Auto-fix code formatting |
564565

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:
580+
581+
```json
582+
"rhdh-e2e-test-utils": "file:/path/to/rhdh-e2e-test-utils"
583+
```
584+
585+
Example:
586+
```json
587+
"rhdh-e2e-test-utils": "file:/Users/yourname/Documents/rhdh/rhdh-e2e-test-utils"
588+
```
589+
590+
#### 3. Install dependencies in the consumer project
591+
592+
```bash
593+
yarn install
594+
```
595+
596+
#### 4. Run tests with NODE_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 package location. 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`.
639+
565640
### CI/CD
566641

567642
The project includes GitHub Actions workflows:

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rhdh-e2e-test-utils",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Test utilities for RHDH E2E tests",
55
"license": "Apache-2.0",
66
"type": "module",
@@ -31,13 +31,10 @@
3131
},
3232
"files": [
3333
"dist",
34-
"tsconfig.base.json",
35-
"src/deployment/rhdh/config",
36-
"src/deployment/rhdh/helm",
37-
"src/deployment/rhdh/operator"
34+
"tsconfig.base.json"
3835
],
3936
"scripts": {
40-
"build": "yarn clean && tsc -p tsconfig.build.json",
37+
"build": "yarn clean && tsc -p tsconfig.build.json && cp -r src/deployment/rhdh/config src/deployment/rhdh/helm src/deployment/rhdh/operator dist/deployment/rhdh/",
4138
"check": "yarn typecheck && yarn lint:check && yarn prettier:check",
4239
"clean": "rm -rf dist",
4340
"lint:check": "eslint . --ignore-pattern dist --ignore-pattern README.md",

src/deployment/rhdh/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ const PACKAGE_ROOT = path.resolve(import.meta.dirname, "../../..");
66
export const DEFAULT_CONFIG_PATHS = {
77
appConfig: path.join(
88
PACKAGE_ROOT,
9-
"src/deployment/rhdh/config/app-config-rhdh.yaml",
9+
"dist/deployment/rhdh/config/app-config-rhdh.yaml",
1010
),
1111
secrets: path.join(
1212
PACKAGE_ROOT,
13-
"src/deployment/rhdh/config/rhdh-secrets.yaml",
13+
"dist/deployment/rhdh/config/rhdh-secrets.yaml",
1414
),
1515
dynamicPlugins: path.join(
1616
PACKAGE_ROOT,
17-
"src/deployment/rhdh/config/dynamic-plugins.yaml",
17+
"dist/deployment/rhdh/config/dynamic-plugins.yaml",
1818
),
1919
helm: {
2020
valueFile: path.join(

0 commit comments

Comments
 (0)