2020-10-09 13:31:45 +00:00
# WooCommerce Core End to End Test Suite
This package contains the automated end-to-end tests for WooCommerce.
## Table of contents
- [Pre-requisites ](#pre-requisites )
- [Setting up core tests ](#setting-up-core-tests )
- [Test functions ](#test-functions )
- [Activation and setup ](#activation-and-setup )
- [Merchant ](#merchant )
- [Shopper ](#shopper )
- [Contributing a new test ](#contributing-a-new-test )
## Pre-requisites
### Setting up the test environment
2021-02-25 23:51:14 +00:00
Follow [E2E setup instructions ](https://github.com/woocommerce/woocommerce/blob/trunk/tests/e2e/README.md ).
2020-10-09 13:31:45 +00:00
### Setting up core tests
- Create the folder `tests/e2e/specs` in your repository if it does not exist.
- To add a core test to your test suite, create a new `.test.js` file within `tests/e2e/specs` . Example code to run all the shopper tests:
```js
const { runShopperTests } = require( '@woocommerce/e2e-core-tests' );
runShopperTests();
```
## Test functions
The functions to access the core tests are:
### Activation and setup
- `runSetupOnboardingTests` - Run all setup and onboarding tests
2021-01-20 16:15:46 +00:00
- `runActivationTest` - Merchant can activate WooCommerce
2021-01-19 13:00:59 +00:00
- `runOnboardingFlowTest` - Merchant can complete onboarding flow
- `runTaskListTest` - Merchant can complete onboarding task list
- `runInitialStoreSettingsTest` - Merchant can complete initial settings
2020-10-09 13:31:45 +00:00
### Merchant
- `runMerchantTests` - Run all merchant tests
2021-01-20 16:15:46 +00:00
- `runCreateCouponTest` - Merchant can create coupon
2021-01-19 13:00:59 +00:00
- `runCreateOrderTest` - Merchant can create order
- `runAddSimpleProductTest` - Merchant can create a simple product
- `runAddVariableProductTest` - Merchant can create a variable product
- `runUpdateGeneralSettingsTest` - Merchant can update general settings
- `runProductSettingsTest` - Merchant can update product settings
- `runTaxSettingsTest` - Merchant can update tax settings
- `runOrderStatusFilterTest` - Merchant can filter orders by order status
- `runOrderRefundTest` - Merchant can refund an order
- `runOrderApplyCouponTest` - Merchant can apply a coupon to an order
2021-01-20 23:19:07 +00:00
- `runProductEditDetailsTest` - Merchant can edit an existing product
- `runProductSearchTest` - Merchant can search for a product and view it
2021-02-09 00:01:21 +00:00
- `runMerchantOrdersCustomerPaymentPage` - Merchant can visit the customer payment page
2021-03-03 16:57:11 +00:00
- `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions
2020-10-09 13:31:45 +00:00
### Shopper
- `runShopperTests` - Run all shopper tests
2021-02-04 19:45:57 +00:00
- `runCartApplyCouponsTest` - Shopper can use coupons on cart
2021-01-20 16:15:46 +00:00
- `runCartPageTest` - Shopper can view and update cart
2021-02-04 19:45:57 +00:00
- `runCheckoutApplyCouponsTest` - Shopper can use coupons on checkout
2021-01-19 13:00:59 +00:00
- `runCheckoutPageTest` - Shopper can complete checkout
- `runMyAccountPageTest` - Shopper can access my account page
2021-02-03 12:13:28 +00:00
- `runSingleProductPageTest` - Shopper can view single product page in many variations (simple, variable, grouped)
2021-02-04 13:44:23 +00:00
- `runProductBrowseSearchSortTest` - Shopper can browse, search & sort products
2021-03-04 09:06:30 +00:00
- `runVariableProductUpdateTest` - Shopper can view and update variations on a variable product
2020-10-09 13:31:45 +00:00
## Contributing a new test
- In your branch create a new `example-test-name.test.js` under the `tests/e2e/core-tests/specs` folder.
- Jest does not allow its global functions to be accessed outside the jest environment. To allow the test code to be published in a package import any jest global functions used in your test
```js
const {
it,
describe,
beforeAll,
} = require( '@jest/globals' );
```
- Wrap your test in a function and export it
```js
const runExampleTestName = () => {
describe('Example test', () => {
beforeAll(async () => {
// ...
});
it('do some example action', async () => {
// ...
});
// ...
});
});
module.exports = runExampleTestName;
```
2021-01-20 16:15:46 +00:00
- Add your test to `tests/e2e/core-tests/specs/index.js`
2020-10-09 13:31:45 +00:00
```js
const runExampleTestName = require( './grouping/example-test-name.test' );
// ...
module.exports = {
// ...
runExampleTestName,
}
```