Skip to content

test(e2e): scope verdaccio registry to workspace config#10435

Open
davidfirst wants to merge 2 commits into
masterfrom
fix-e2e-registry-workspace-scope
Open

test(e2e): scope verdaccio registry to workspace config#10435
davidfirst wants to merge 2 commits into
masterfrom
fix-e2e-registry-workspace-scope

Conversation

@davidfirst

Copy link
Copy Markdown
Member

E2E tests set the npm registry with bit config set registry <verdaccio-url>, which defaults to Bit's global config store. When the suite runs locally, the local verdaccio URL leaks into every other Bit workspace, so unrelated installs try to reach the (now-dead) local registry.

Pass --local-track so the registry is written to the test workspace's workspace.jsonc (origin workspace) instead of the global config. getConfig still reads it during install, but it's confined to the throwaway test workspace. Also removed the now-redundant delConfig('registry') cleanup calls.

Tests set the npm registry via 'bit config set registry', which defaults
to Bit's global config and leaks the local verdaccio URL into every
workspace when run locally. Pass --local-track so it's written to the
test workspace's workspace.jsonc instead, and drop the now-redundant
delConfig('registry') cleanup calls.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

E2E: write verdaccio registry to workspace config (avoid global Bit config leak)
🧪 Tests 🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

Description

• Scope E2E npm registry configuration to the test workspace via --local-track.
• Prevent local verdaccio URLs from leaking into developers’ global Bit config.
• Remove redundant registry cleanup calls since tests no longer touch global config.
Diagram

graph TD
  T[E2E test] --> C["setConfig registry (--local-track)"] --> W[["workspace.jsonc"]] --> I[Bit install] --> V{{Verdaccio}}
  C -. avoids write .-> G[(Global Bit config)]
  subgraph Legend
    direction LR
    _p[Process] ~~~ _f[[File]] ~~~ _db[(Store)] ~~~ _ext{{External}}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use env var registry (NPM_CONFIG_REGISTRY) per install
  • ➕ Zero persistence (no file writes) and naturally scoped to a single process/test.
  • ➕ Avoids relying on Bit config scoping semantics.
  • ➖ May not exercise the same codepath Bit uses to read registry from config (reduced coverage).
  • ➖ Harder to ensure all internal subprocesses inherit env consistently.
2. Redirect Bit global config path to a temp location in tests
  • ➕ Keeps current CLI behavior while guaranteeing no developer config pollution.
  • ➕ Doesn’t require changing how tests set registry.
  • ➖ More invasive harness change; risk of missing other places that read config path.
  • ➖ Potentially diverges from real-world behavior if other global config values matter.

Recommendation: Keep the PR’s approach: passing --local-track makes the registry setting belong to the throwaway test workspace (workspace.jsonc) while still being read by install. It fixes the real developer pain (global config pollution) without introducing env-propagation fragility or changing the test harness’s config storage model.

Files changed (6) +31 / -39

Tests (6) +31 / -39
allow-scripts.e2e.tsScope registry to workspace and simplify cleanup in allow-scripts E2E +20/-17

Scope registry to workspace and simplify cleanup in allow-scripts E2E

• Passes '--local-track' when setting the npm registry so it is written to the test workspace config instead of global Bit config. Removes registry deletion in after hooks and applies minor formatting for long install arguments.

e2e/harmony/dependencies/allow-scripts.e2e.ts

never-built-dependencies.e2e.tsWrite verdaccio registry to workspace config for never-built-dependencies E2E +2/-4

Write verdaccio registry to workspace config for never-built-dependencies E2E

• Updates registry setup to include '--local-track' so it does not leak into global config. Drops redundant registry cleanup since the setting is now confined to the workspace.

e2e/harmony/dependencies/never-built-dependencies.e2e.ts

deps-graph-isolation.e2e.tsScope registry configuration to workspace in deps-graph isolation tests +2/-4

Scope registry configuration to workspace in deps-graph isolation tests

• Ensures the test registry is set with '--local-track' for workspace-only persistence. Removes post-test global registry cleanup calls.

e2e/harmony/deps-graph-isolation.e2e.ts

deps-graph-reimport.e2e.tsUse workspace-scoped registry for deps-graph reimport E2E +2/-4

Use workspace-scoped registry for deps-graph reimport E2E

• Switches registry configuration to '--local-track' so reimport scenarios don’t modify global Bit config. Removes redundant cleanup of the registry config in after hooks.

e2e/harmony/deps-graph-reimport.e2e.ts

deps-graph.e2e.tsPrevent global registry pollution in deps-graph E2E +3/-6

Prevent global registry pollution in deps-graph E2E

• Adds '--local-track' to registry setup across deps-graph scenarios to keep verdaccio scoped to the test workspace. Removes global registry deletion from teardown blocks.

e2e/harmony/deps-graph.e2e.ts

install.e2e.tsScope registry to workspace for install E2E scenarios +2/-4

Scope registry to workspace for install E2E scenarios

• Updates install tests to set the verdaccio registry using '--local-track' so local runs don’t impact other workspaces. Removes registry cleanup in teardown since global config is no longer touched.

e2e/harmony/install.e2e.ts

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 19, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Reimport drift no longer scoped 🐞 Bug ☼ Reliability
Description
In deps-graph-reimport.e2e.ts and deps-graph.e2e.ts, the tests set the registry via --local-track
and then call reInitWorkspace() one or more times, but continue with installs/imports in the new
workspace without reapplying the registry, which can either hit the default registry or stop
exercising the intended reimport/drift regression scenarios.
Code

e2e/harmony/deps-graph-reimport.e2e.ts[39]

+      helper.command.setConfig('registry', npmCiRegistry.getRegistryUrl(), '--local-track');
Evidence
The cited tests configure the registry using bit config set ... --local-track, which persists the
setting into workspace.jsonc; however, reInitWorkspace() wipes the workspace directory, removing
workspace.jsonc and thus the workspace-scoped registry configuration. After those workspace
resets, both suites proceed to run install/import steps (and rely on registry-mock state mutated
via addDistTag()), but because the registry setting is no longer present in the fresh workspace,
those operations may run against the default registry, causing resolution failures or making drift
assertions meaningless because the mock registry’s updated dist-tags are not being used.

e2e/harmony/deps-graph-reimport.e2e.ts[29-74]
e2e/harmony/deps-graph-reimport.e2e.ts[87-155]
components/legacy/e2e-helper/e2e-scope-helper.ts[61-72]
components/config-store/config-cmd.ts[9-30]
scopes/workspace/workspace/workspace.ts[384-404]
e2e/harmony/deps-graph.e2e.ts[29-37]
e2e/harmony/deps-graph.e2e.ts[168-218]
e2e/harmony/deps-graph.e2e.ts[147-165]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The deps-graph E2E tests set `registry` using `bit config set ... --local-track`, which persists into `workspace.jsonc`, but later call `helper.scopeHelper.reInitWorkspace()` which empties the workspace directory and removes `workspace.jsonc`. After re-initialization, the tests continue running `install`/`import` steps without reapplying the mocked registry, so those operations may hit the default registry and either fail or stop validating the intended reimport/drift regression behavior.

## Issue Context
These suites use registry-mock and `addDistTag()` to mutate registry state and create drift-sensitive conditions; if later steps are executed without the mock registry configured in the newly initialized workspace, the test can pass for the wrong reason (the newer dist-tagged versions aren’t visible) or fail because packages cannot be resolved.

## Fix Focus Areas
- e2e/harmony/deps-graph-reimport.e2e.ts[29-74]
- e2e/harmony/deps-graph-reimport.e2e.ts[87-155]
- e2e/harmony/deps-graph.e2e.ts[147-218]
- e2e/harmony/deps-graph.e2e.ts[244-289]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 51e52ca

Results up to commit f79e073


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Qodo Logo

npmCiRegistry.configureCustomNameInPackageJsonHarmony(name);
await npmCiRegistry.init();
helper.command.setConfig('registry', npmCiRegistry.getRegistryUrl());
helper.command.setConfig('registry', npmCiRegistry.getRegistryUrl(), '--local-track');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Reimport drift no longer scoped 🐞 Bug ☼ Reliability

In deps-graph-reimport.e2e.ts and deps-graph.e2e.ts, the tests set the registry via --local-track
and then call reInitWorkspace() one or more times, but continue with installs/imports in the new
workspace without reapplying the registry, which can either hit the default registry or stop
exercising the intended reimport/drift regression scenarios.
Agent Prompt
## Issue description
The deps-graph E2E tests set `registry` using `bit config set ... --local-track`, which persists into `workspace.jsonc`, but later call `helper.scopeHelper.reInitWorkspace()` which empties the workspace directory and removes `workspace.jsonc`. After re-initialization, the tests continue running `install`/`import` steps without reapplying the mocked registry, so those operations may hit the default registry and either fail or stop validating the intended reimport/drift regression behavior.

## Issue Context
These suites use registry-mock and `addDistTag()` to mutate registry state and create drift-sensitive conditions; if later steps are executed without the mock registry configured in the newly initialized workspace, the test can pass for the wrong reason (the newer dist-tagged versions aren’t visible) or fail because packages cannot be resolved.

## Fix Focus Areas
- e2e/harmony/deps-graph-reimport.e2e.ts[29-74]
- e2e/harmony/deps-graph-reimport.e2e.ts[87-155]
- e2e/harmony/deps-graph.e2e.ts[147-218]
- e2e/harmony/deps-graph.e2e.ts[244-289]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 51e52ca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant