feat(administration): ship a Jest config factory with the extension tooling by gweiermann · Pull Request #21797 · shopware/shopware · GitHub
Skip to content

feat(administration): ship a Jest config factory with the extension tooling - #21797

Open
Gerrit Weiermann (gweiermann) wants to merge 8 commits into
trunkfrom
feat/admin-extension-jest-config
Open

Gerrit Weiermann (gweiermann) wants to merge 8 commits into
trunkfrom
feat/admin-extension-jest-config

Conversation

@gweiermann

@gweiermann Gerrit Weiermann (gweiermann) commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

1. Why is this change necessary?

Jest in SwagCommercial and other extensions missed / will miss these features:

  • shopware:* virtual modules
  • triggerDeprecationOrThrow() baseline and assertions
  • it.deprecated() / it.activeFeatureFlags() helper

The extension tooling already gives extensions their TypeScript and ESLint config from the installed Administration. Jest was missing.

2. What does this change do, exactly?

  • New extension-tooling/jest.mjs with shopwareAdminJest(options)
  • The Administration's own Jest uses it
  • Extensions add their own options on top: setup files, mappings and transforms merge with the harness, an allowlist of other Jest options replaces the default, anything else (e.g. testEnvironment) throws
  • Vue, @vue/test-utils, Pinia, vue-i18n, vue-router and Meteor resolve to the Administration's copy, so specs share one instance with the Administration code they mount
  • A missing generated file (component import map, entity schema) fails with the command that creates it
  • Setup generates a .shopware/jest.mjs
  • No jest.config.mjs is scaffolded, extensions opt in
  • Experimental, like the rest of the extension tooling

Currently weird:

3. Describe each step to reproduce the issue or behaviour.

In a plugin under custom/plugins:

// src/Resources/app/administration/jest.config.mjs
export { default } from './.shopware/jest.mjs';

// src/Resources/app/administration/src/main.spec.js
import { createId } from 'shopware:utils';

it('runs on the Administration test setup', () => {
    expect(createId()).toMatch(/^[0-9a-f]{32}$/);
    Shopware.Feature.triggerDeprecationOrThrow('V6_8_0_0', 'oldApi() is deprecated.');
});
  1. composer admin:setup-extension-tooling
  2. node <administration>/node_modules/jest/bin/jest.js --config jest.config.mjs in the plugin's Administration folder
  3. The spec passes. V6_8_0_0=1 makes the deprecation throw.

SwagCommercial's full suite on its trunk config and on the factory (through the bridge): 5447 tests each, 0 tests changed status.

4. Please link to the relevant issues (if any).

5. Checklist

  • I have written tests and verified that they fail without my change
  • I have updated developer-facing release notes if this change is relevant for external developers:
    • Add a short entry to RELEASE_INFO-6.<current major line>.md in the upcoming version section for informational changes: what changed, who is affected, and how to adapt.
    • Add an entry to UPGRADE-6.<next major>.md for breaking changes and deprecations: what changed, who is affected, and how to adapt.
    • See the Documenting a Release Process for details.
  • I have written or adjusted the documentation and agent skills according to my changes
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I have read the contribution requirements and fulfilled them

@gweiermann Gerrit Weiermann (gweiermann) added component/administration domain/framework Responsible for the framework-level code includes core, administration, storefront, and frontends labels Oct 20, 2026
@github-actions github-actions Bot added the major/6.8 Collects all pull requests related to major release 6.8 label Oct 20, 2026
@github-actions github-actions Bot added the waiting-on/nobody The PR is a draft or parked. Set daily by the waiting-on-report workflow. label Oct 20, 2026
@shopware-octo-sts-app-2 shopware-octo-sts-app-2 Bot added the major-php Run major PHPUnit integration tests label Oct 20, 2026
@github-actions github-actions Bot added the major/6.8-cleanup Collects all pull requests related to major release 6.8 cleanup label Oct 21, 2026
…ooling

Extensions such as SwagCommercial run their specs on the Administration's
test harness but copy its Jest config by hand, so harness changes like the
shopware:* virtual modules or the feature flag registry behind
triggerDeprecationOrThrow never reach them.

extension-tooling/jest.mjs now owns the harness: environment, setup files,
transforms and host module mapping, all resolved into the installed
Administration. The Administration's own Jest config composes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…extension

Setup now writes .shopware/jest.mjs next to the tsconfig and ESLint
bridges. It re-exports the factory of the installed Administration, so an
extension's jest.config.mjs imports it and only adds its own options.
No jest.config.mjs is scaffolded, because not every extension has specs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tory

The factory spread every unknown option into the config. An extension could
replace testEnvironment or resolver and silently lose it.activeFeatureFlags(),
and its transformIgnorePatterns was overwritten by the harness default.

The factory now merges the harness options (plus testEnvironmentOptions),
lets an explicit allowlist replace the default, and throws on any other
option with the list of accepted ones. It also keeps the harness on the
installed Administration:

- globals.adminPath, the vue-jest tsConfig and ADMIN_PATH stay pinned to it.
- Pinia, vue-i18n and vue-router resolve to its copies, like Vue and the
  Meteor packages, so a spec and the code it mounts share one instance.
- Only src/ imports map into it, so a package such as srcdoc-polyfill
  stays untouched.
- The meta-glob Babel transform matches only its own files, so an
  extension's src/module/index.ts stays on SWC.
- HOST_TRANSFORMED_PACKAGES and HOST_TRANSFORM_IGNORE_PATTERNS export its
  frozen transform defaults, so a replaced transformIgnorePatterns keeps them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e of the jest harness

The harness reads two files that every installation generates itself:
the component import map and the entity schema. The factory checked only
the first, so a missing entity schema surfaced as an unresolved import in
the first spec.

The factory now lists every missing generated file with the command that
generates it. It still fails first, and with its own message, when the
Administration ships no test/ folder at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e end to end

The e2e sets up a plugin in a temporary project and runs its specs with the
Administration's Jest through the generated .shopware/jest.mjs bridge. The
specs resolve the shopware:* virtual modules, warn about a deprecation
before its major and throw once the major is active, and mount a TypeScript
setup SFC and a Twig template. The SFC spreads a Set, which renders nothing
unless vue-jest compiles it with the Administration's tsconfig.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The extension-tooling README explains how an extension composes the
factory, which options merge and which replace, how to transform an
additional ESM package, and which generated files the harness needs.
RELEASE_INFO announces the factory as experimental extension tooling that
runs in a platform checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gweiermann
Gerrit Weiermann (gweiermann) marked this pull request as ready for review October 21, 2026 14:56
@github-actions github-actions Bot added waiting-on/shopware The PR is waiting on shopware. Set daily by the waiting-on-report workflow. and removed waiting-on/nobody The PR is a draft or parked. Set daily by the waiting-on-report workflow. labels Oct 21, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

@shopwareBot

shopwareBot commented Oct 21, 2026 •

Copy link
Copy Markdown

@gweiermann
Gerrit Weiermann (gweiermann) marked this pull request as draft October 22, 2026 08:12
@github-actions github-actions Bot added waiting-on/nobody The PR is a draft or parked. Set daily by the waiting-on-report workflow. and removed waiting-on/shopware The PR is waiting on shopware. Set daily by the waiting-on-report workflow. labels Oct 22, 2026
…est factory

The stack makes the Composer package ship the Jest setup files, so the
factory no longer needs to reject an Administration without test/_setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gweiermann
Gerrit Weiermann (gweiermann) marked this pull request as ready for review October 23, 2026 06:31
@github-actions github-actions Bot added waiting-on/shopware The PR is waiting on shopware. Set daily by the waiting-on-report workflow. and removed waiting-on/nobody The PR is a draft or parked. Set daily by the waiting-on-report workflow. labels Oct 23, 2026
@github-actions github-actions Bot added waiting-on/author The PR is waiting on its author. Set daily by the waiting-on-report workflow. and removed waiting-on/shopware The PR is waiting on shopware. Set daily by the waiting-on-report workflow. labels Oct 24, 2026

This branch has not been deployed

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

Labels

component/administration domain/framework Responsible for the framework-level code includes core, administration, storefront, and frontends major/6.8-cleanup Collects all pull requests related to major release 6.8 cleanup major/6.8 Collects all pull requests related to major release 6.8 major-php Run major PHPUnit integration tests milestone/6.7.17.0 waiting-on/author The PR is waiting on its author. Set daily by the waiting-on-report workflow.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants