Salesforce Commerce Cloud QA test suite is one of the latest features introduced in the Storefront Reference Architecture (SFRA). You can use this feature to test applications end-to-end without using any third-party testing framework. It is recommended to upgrade to SFRA from SiteGenesis, if you want to utilize this feature. The SFRA repository provides default-test scenarios for pages, like account page, home page, checkout page, etc., that can be added or modified based on your business requirements.
However, since every advantage comes with a corresponding shortcoming, let’s take a look at some of the limitations of the QA test suite below:
The following steps are for the latest version of SFRA 4.4.1.
Step 1: Clone the SFRA's latest repository, storefront-reference-architecture-master.
Step 2: To get all dependencies into the local, run ‘npm install.’ Once the command is executed, you can view all dependencies in the package.json file.
Step 3: Create 'dw.json' file in the root of the project.
```json
{
"hostname": "your-sandbox-hostname.demandware.net",
"username": "yourlogin",
"password": "yourpwd",
"code-version": "version_to_upload_to"
}
EX:
{
"hostname": "dev99-t01-toy.demandware.net",
"username": "your.emailid@client.com",
"password": "your sandbox password",
"code-version": "your code version in BM"
}
This file is located in dw.json as shown below:
Step 4: Run ‘npm run compile:js’ from the command line that would compile all client-side JavaScript files. Run ‘npm run compile:scss’ and ‘npm run compile:fonts’ that would do the same for CSS and fonts.
Step 5: Run ‘npm run uploadCartridge.’ It will upload ‘app_storefront_base,’ ‘modules,’ and ‘bm_app_storefront_base’ cartridges to the sandbox you have specified in the ‘dw.json’ file.
Step 6: Add the ‘app_storefront_base’ cartridge to your cartridge path in _Administration > Sites > Manage Sites > Sitegen - Settings_
Step 7: Run NPM scripts - Use the provided NPM scripts to compile and upload changes to your Sandbox.
Step 8: Compile your application with the following commands:
* `npm run compile:scss` - Compiles all .scss files into CSS.
* `npm run compile:js` - Compiles all .js files and aggregates them.
* `npm run compile:fonts` - Copies all needed font files. It is usually run just once.
Let’s discuss some of the key functions that you can perform with the QA test suite.
The Storefront includes multiple pages for every page type—home page, address page, account page, login page, etc.—that has positive and negative scenarios available for them. These scenarios can be easily found under a test folder, as shown below:
Examples of Scenarios:
Positive Scenario: Create an Account
As a shopper, you want to create an account with the site
Negative Scenario: Create an Account (Negative)
As a user, you can generate a coverage report for all scenarios based on the data and can find all coverage details under the coverage folder. You can open coverage.json to see all coverage details.
For the report generated under the coverage folder, you can find and open Index.html to see the detailed report on the browser.
You can see a test case’s success or failure in the terminal while running a command npm cover. In the terminal, it will show all successful and failed scenarios/cases— the successful cases are represented in green color and the failed one are in red.
The command ‘npm run lint’ execute linting for all JavaScript and SCSS files in the project. You must run this command before committing your code.
The command ‘npm run watch’ watches everything, recompiles (if necessary), and uploads to the sandbox. It requires a valid dw.json file at the root that is configured for the sandbox to upload.
You can run ‘npm test’ to execute all unit tests in the project. Run ‘npm run cover’ to get coverage information. Coverage information will be available in the ‘coverage’ folder under the root directory.
With the latest QA test suite, you do not need any external testing framework to test your application as it allows the rapid testing of applications. It will cater to most of your testing needs but does have some limitations. However, it is much convenient to construct cases and test workflow using an internal QA test suite as compared to an external tool.