Skip to content

add SHOPIFY_CLI_ENV=development for test commands#6998

Open
phyllis-sy-wu wants to merge 1 commit intomainfrom
psyw-0312-add-SHOPIFY_CLI_ENV_development-for-dev-test
Open

add SHOPIFY_CLI_ENV=development for test commands#6998
phyllis-sy-wu wants to merge 1 commit intomainfrom
psyw-0312-add-SHOPIFY_CLI_ENV_development-for-dev-test

Conversation

@phyllis-sy-wu
Copy link
Contributor

@phyllis-sy-wu phyllis-sy-wu commented Mar 12, 2026

WHY are these changes introduced?

Test scripts need to run with the development environment so behaviour and configuration match the intended setup. Without SHOPIFY_CLI_ENV=development, some tests fail due to a missing or incorrect environment variable.

Relevant discussion: https://shopify.slack.com/archives/C05E3BDFDRB/p1773343132505319

Context

There are three ways to run tests locally:

  1. dev commands (dev.yml)
    • For internal Shopify engineers.
    • SHOPIFY_CLI_ENV=development is set in dev.yml.
    • After dev up, dev test runs in the correct environment.
  2. pnpm scripts (package.json)
    • For external contributors and internal engineers.
    • Commands
      pnpm test:e2e
      pnpm test:unit
      pnpm test
    • Today these do not set SHOPIFY_CLI_ENV=development, so some tests can fail unless the caller sets it.
  3. Direct commands
    • Example: pnpm vitest run
    • Same issue unless the user sets the env var.

WHAT is this pull request doing?

Setting SHOPIFY_CLI_ENV=development for the relevant pnpm test scripts in package.json so that tests run in the same development context whether invoked via dev test or via pnpm test / pnpm test:unit / etc., for both external developers and internal engineers.

How to test your changes?

TBD

  1. Run dev test and verify that all tests execute successfully
  2. Remove the SHOPIFY_CLI_ENV=development and run dev test to observe the failure in four tests.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@phyllis-sy-wu phyllis-sy-wu marked this pull request as ready for review March 12, 2026 22:46
@phyllis-sy-wu phyllis-sy-wu requested a review from a team as a code owner March 12, 2026 22:46
@github-actions
Copy link
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 77.22% 14548/18839
🟡 Branches 70.91% 7217/10178
🟡 Functions 76.2% 3698/4853
🟡 Lines 78.72% 13753/17471

Test suite run success

3806 tests passing in 1462 suites.

Report generated by 🧪jest coverage report action from 13bbcda

"test:regenerate-snapshots": "nx build cli && packages/features/snapshots/regenerate.sh",
"test:unit": "pnpm vitest run",
"test:unit": "SHOPIFY_CLI_ENV=development pnpm vitest run",
"test": "pnpm vitest run && pnpm nx run features:test",
Copy link
Contributor

Choose a reason for hiding this comment

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

should also be here

Copy link
Contributor

@ryancbahan ryancbahan left a comment

Choose a reason for hiding this comment

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

nice job! let's just make sure all the package.json commands that need this env var have it

@phyllis-sy-wu phyllis-sy-wu changed the title add SHOPIFY_CLI_ENV=development for dev test add SHOPIFY_CLI_ENV=development for test commands Mar 13, 2026
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.

2 participants