パッケージの詳細

@shopware-ag/jest-preset-sw6-admin

shopware74.2kMIT6.0.1

Jest Test preset for Shopware 6 administration unit tests

jest, unit, test, unit-test

readme

Jest Test preset for Shopware 6 administration unit tests

GitHub GitHub last commit Libraries.io Latest version

Default Jest preset for Shopware 6 administration development.

npm install jest @shopware-ag/jest-preset-sw6-admin @babel/preset-env @babel/plugin-proposal-class-properties --save-dev

Setup

After installaing the necessary required packages, please create a file called babel.config.json right next to your own package.json with the following content:

{
    "presets": ["@babel/preset-env"],
    "plugins": ["@babel/plugin-proposal-class-properties"]
}

Via jest.config.js

Next up, create a file jest.config.js which should contain the following content:

module.exports = {
    preset: '@shopware-ag/jest-preset-sw6-admin',
    globals: {
        adminPath: '<file-path-to-sw6-administration>', // required, e.g. /www/sw6/platform/src/Administration/Resources/app/administration
    }
}

Options the preset sets up for you

  • collectCoverage - Code coverage will be generated using the reporters listed under coverageReporters
  • coverageReporters - The presets uses lcov, text & clover as coverage reporters
  • watchPathIgnorePatterns - Ignores the node_modules folder for the watch mode of Jest
  • clearMocks - Automatically clear mock calls and instances before every test.
  • moduleFileExtensions - File with the extension js will automatically used as extensions your module use.
  • moduleNameMapper - All css, less & scss files will be mocked and relative paths to src are getting mapped to the correct src directory
  • transform - Transforms js files using babel-jest and twig files are transformed using a custom twig transformer which we use in the administration as well
  • modulePathIgnorePatterns - Ignores e2e test specs by default
  • setupFilesAfterEnv - Provides a polyfill for Webpack' require.context and sets up the global Shopware third-party interface for every test. The object can be accessed using global.Shopware in test files.
  • testMatch - Matches all files containing .spec.js in the test directory

更新履歴

Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[v6.0.1] - 2025-02-07

  • Replace babel-plugin-transform-vite-meta-glob with babel-plugin-shopware-vite-meta-glob

[v6.0.0] - 2025-02-06

  • Breaking change: Removed require.context support for Webpack code.
  • Added support for import.meta.glob for Vite code.

[v5.0.0] - 2025-02-06

Changed

  • Breaking change: Removed support for the Vue 2 compatibility mode. The Vue 3 mode is now the default mode.

[v4.3.4] - 2024-06-26

Changed

  • Changed global Pinia store to be added to created app instance instead of global Vue object which only works with Vue compat mode

Changed

  • Activate feature flag "DISABLE_VUE_COMPAT" when Vue compat mode is disabled

[v4.3.3] - 2024-06-25

Changed

  • Activate feature flag "DISABLE_VUE_COMPAT" when Vue compat mode is disabled

[v4.3.2] - 2024-06-17

Changed

  • Enabled Pinia support in setup-env-for-shopware.js

[v4.3.1] - 2024-06-13

Changed

  • Enable the console warnings when Vue compat mode is disabled

[v4.3.0] - 2024-06-12

Added

  • Added the possibiliy to disable the Vue compat mode by setting the environment variable DISABLE_JEST_COMPAT_MODE to true

[v4.2.5] - 2024-05-28

Changed

  • Changed setup-env-for-shopware.js to hide console.warn as long as Vue compat is enabled

[v4.2.4] - 2024-05-07

Added

  • Added support for platform *.vite files

[v4.2.3] - 2024-01-17

Added

  • Added meteor-admin-sdk to transform option

[v4.2.2] - 2023-08-25

Added

  • Added window._features_.vue3 in Vue 2 with false

[v4.2.1] - 2023-08-25

Changed

  • Changed a wrong negation for the Vue 3 flag

[v4.2.0] - 2023-08-25

Added

  • Added Vue 3 support

Changed

  • Changed twig-to-vue-transformer to replace html and vue comments with empty strings similar to our webpack setup

    [v4.1.0] - 2023-07-26

Added

  • Added @babel/preset-env to transform test env

    [v4.0.2] - 2023-04-14

Changed

  • Make default imports for mixins, directives, filters, states and the component helper independent of file type (TS or JS)

    [v4.0] - 2022-10-20

Only load *.spec.js|ts from src

Added

  • Added support for spec files in the src folder.

Removed

  • Removed support for spec files in the test folder.

[v3.1] - 2022-10-13

Here we added support to transform .html files.

Added

  • Added transform support for .html files.