woocommerce/tests/e2e/core-tests
rodel 2c3bec8429 Tests for "Add shipping classes" 2021-03-21 06:07:50 -07:00
..
specs Tests for "Add shipping classes" 2021-03-21 06:07:50 -07:00
CHANGELOG.md Merge branch 'trunk' into e2e/e2e-merchant-search-orders 2021-03-17 09:07:51 +01:00
README.md Merge branch 'trunk' into e2e/e2e-merchant-search-orders 2021-03-17 09:07:51 +01:00
index.js add readme to core tests package 2020-10-09 10:31:45 -03:00
package.json merge trunk 2021-03-02 14:28:16 -04:00

README.md

WooCommerce Core End to End Test Suite

This package contains the automated end-to-end tests for WooCommerce.

Table of contents

Pre-requisites

Setting up the test environment

Follow E2E setup instructions.

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:

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
    • runActivationTest - Merchant can activate WooCommerce
    • runOnboardingFlowTest - Merchant can complete onboarding flow
    • runTaskListTest - Merchant can complete onboarding task list
    • runInitialStoreSettingsTest - Merchant can complete initial settings

Merchant

  • runMerchantTests - Run all merchant tests
    • runCreateCouponTest - Merchant can create coupon
    • 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
    • runProductEditDetailsTest - Merchant can edit an existing product
    • runProductSearchTest - Merchant can search for a product and view it
    • runMerchantOrdersCustomerPaymentPage - Merchant can visit the customer payment page
    • runOrderSearchingTest - Merchant can search for order via different terms
    • runAddNewShippingZoneTest - Merchant can create shipping zones and let shopper test them
    • runMerchantOrderEmailsTest - Merchant can receive order emails and resend emails by Order Actions

Shopper

  • runShopperTests - Run all shopper tests
    • runCartApplyCouponsTest - Shopper can use coupons on cart
    • runCartPageTest - Shopper can view and update cart
    • runCheckoutApplyCouponsTest - Shopper can use coupons on checkout
    • runCheckoutPageTest - Shopper can complete checkout
    • runMyAccountPageTest - Shopper can access my account page
    • runSingleProductPageTest - Shopper can view single product page in many variations (simple, variable, grouped)
    • runMyAccountPayOrderTest - Shopper can pay for his order in My Account
    • runCartApplyCouponsTest - Shopper can apply coupons in the cart
    • runCheckoutApplyCouponsTest - Shopper can apply coupons in the checkout
    • runProductBrowseSearchSortTest - Shopper can browse, search & sort products
    • runVariableProductUpdateTest - Shopper can view and update variations on a variable product

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
const {
	it,
	describe,
	beforeAll,
} = require( '@jest/globals' );
  • Wrap your test in a function and export it
const runExampleTestName = () => {
	describe('Example test', () => {
		beforeAll(async () => {
			// ...
		});

		it('do some example action', async () => {
            // ...
		});
        // ...
    });
});

module.exports = runExampleTestName;
  • Add your test to tests/e2e/core-tests/specs/index.js
const runExampleTestName = require( './grouping/example-test-name.test' );
// ...
module.exports = {
// ...
    runExampleTestName,
}