Jest Test preset for Shopware 6 administration unit tests
Default Jest preset for Shopware 6 administration development.
npm install @shopware-ag/jest-preset-sw6-admin --save-dev
Setup
Via jest.config.json
or jest
field in package.json
{
"preset": "@shopware-ag/jest-preset-sw6-admin
}
Usage
It's important to configure the preset using the following configuration:
module.exports = {
preset: '@shopware-ag/jest-preset-sw6-admin',
globals: {
artifactsPath: 'build/artifacts',
adminPath: '<path-to-sw6-administration>',
suiteName: 'My Shopware 6 jest test suite'
}
}
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 reporterscoverageDirectory
- Code coverage will be generated into the globals.artifactsPath
, if undefined
, it will be generated into the folder which contains the jest.config.js
/ package.json
filewatchPathIgnorePatterns
- Ignores the node_modules
folder for the watch mode of JestclearMocks
- 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 directorytransform
- Transforms js
files using babel-jest and twig
files are transformed using a custom twig transformer which we use in the administration as wellmodulePathIgnorePatterns
- Ignores e2e test specs by defaultsetupFilesAfterEnv
- 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 directoryreporters
- Uses the reporters default
and jest-junit
. jest-junit
is automatically configured. It can be customized using global.suiteName
& global.artifactsPath