@shopgate/pwa-unit-test
v7.12.9
Published
The unit tests setup for Shopgate's ENGAGE.
Downloads
1,910
Keywords
Readme
Unit test setup for the Shopgate Connect PWA
This test suite is a configuration for Shopgate's React projects.
The unit test suite needs React to be installed in at least version ~16.2.0
This configuration uses Jest for running the tests. It is only an extension of the default Jest configuration and prepares your tests for any React PWA using the Shopgate Cloud.
Installation
To install and use this package, you need to run the following command in your project's root directory:
npm install @shopgate/pwa-unit-test --save-dev
Usage
All test files should follow the naming convention of *spec.(js|jsx)
.
You have two options of how to create a configuration for Jest:
- You can create your own configuration following the Jest Documentation
- You can use Shopgate's pre-defined configuration and extend it as you wish.
NOTE: Using and extending the Shopgate configuration is the preferred way!
1. Using Shopgate's configuration
Create a file called jest.config.js
in the root of your project.
Add the following line to it:
module.exports = require('@shopgate/pwa-unit-test/jest.config');
2. Extending Shopgate's configuration
Create a file called jest.config.js
in the root of your project.
Add the following line in the beginning of the file:
const defaultConfig = require('@shopgate/pwa-unit-test/jest.config');
This will load the default configuration. Now you can extend it by spreading the defaultConfig
into a newly created configuration object:
module.exports = {
...defaultConfig,
[Your config goes here],
};
Example Configuration
Here is an example showing how to extend the default configuration:
const defaultConfig = require('@shopgate/pwa-unit-test/jest.config');
module.exports = {
...defaultConfig,
moduleNameMapper: {
'^Components(.*)$': '<rootDir>/components',
'^Styles(.*)$': '<rootDir>/styles',
},
};
About Shopgate
Shopgate is the leading mobile commerce platform.
Shopgate offers everything online retailers need to be successful in mobile. Our leading software-as-a-service (SaaS) enables online stores to easily create, maintain and optimize native apps and mobile websites for the iPhone, iPad, Android smartphones and tablets.
License
Unit test setup for the Shopgate Connect PWA is available under the Apache License, Version 2.0.
See the LICENSE.md file for more information.