95bc1189e5
This bumps the version to 0.14.3 so that we can take advantage of some upstream improvements. It also makes some changes to the way our builds and watches work to minimize the number of unnecessary Node processes involved in the execution. |
||
---|---|---|
.. | ||
bin | ||
changelog | ||
installFiles | ||
src | ||
test-data | ||
.eslintrc.js | ||
.gitignore | ||
CHANGELOG.md | ||
NEXT_CHANGELOG.md | ||
README.md | ||
core-tests-root.js | ||
package.json |
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
Version 0.2.0 or newer
Version 0.2.0 added a test installer that will populate the tests/e2e/specs
folder with test scripts for all the current core test suite. It also creates sample configuration files including all the configuration data needed to run the core tests.
- Install the e2e-environment
npm install @woocommerce/e2e-environment --save-dev
- Run the installer
npx wc-e2e install @woocommerce/e2e-core-tests
- Merge the sample configuration files:
tests/e2e/docker/woocommerce.e2e-core-tests.sh
=>initialize.sh
tests/e2e/config/default-woocommerce.e2e-core-tests.json
=>default.json
Version 0.1.X or other test runner
- 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 withintests/e2e/specs
. Example code to run all the shopper tests:
const { runShopperTests } = require( '@woocommerce/e2e-core-tests' );
runShopperTests();
Retrying/Re-running tests
On a new site, the setup and activation tests prepare the site for the remainder of the tests. To retry/rerun the test suite on a site where setup/onboarding test have already run use the environment variable E2E_RETEST=1
.
Test functions
The functions to access the core tests are:
Activation and setup
runSetupOnboardingTests
- Run all setup and onboarding testsrunActivationTest
- Merchant can activate WooCommercerunOnboardingFlowTest
- Merchant can complete onboarding flowrunTaskListTest
- Merchant can complete onboarding task listrunInitialStoreSettingsTest
- Merchant can complete initial settings
Merchant
runMerchantTests
- Run all merchant testsrunAddShippingClassesTest
- Merchant can create shipping classes and let shopper test themrunAddNewShippingZoneTest
- Merchant can create shipping zones and let shopper test themrunAddSimpleProductTest
- Merchant can create a simple productrunAddVariableProductTest
- Merchant can create a variable productrunCreateCouponTest
- Merchant can create couponrunCreateOrderTest
- Merchant can create orderrunMerchantOrdersCustomerPaymentPage
- Merchant can visit the customer payment pagerunMerchantOrderEmailsTest
- Merchant can receive order emails and resend emails by Order ActionsrunEditOrderTest
- Merchant can edit an order in the dashboardrunOrderStatusFilterTest
- Merchant can filter orders by order statusrunOrderRefundTest
- Merchant can refund an orderrunOrderApplyCouponTest
- Merchant can apply a coupon to an orderrunOrderSearchingTest
- Merchant can search for order via different termsrunProductEditDetailsTest
- Merchant can edit an existing productrunProductSearchTest
- Merchant can search for a product and view itrunProductSettingsTest
- Merchant can update product settingsrunTaxSettingsTest
- Merchant can update tax settingsrunUpdateGeneralSettingsTest
- Merchant can update general settingsrunMerchantOrderEmailsTest
- Merchant can receive order emails and resend emails by Order ActionsrunAnalyticsPageLoadsTest
- Merchant can load and see all pages in AnalyticsrunImportProductsTest
- Merchant can import products via CSV filerunInitiateWccomConnectionTest
- Merchant can initiate connection to Woo.comrunAdminPageLoadTests
- Merchant can load pages from the WP Admin sidebar
Shopper
runShopperTests
- Run all shopper testsrunCartApplyCouponsTest
- Shopper can use coupons on cartrunCartPageTest
- Shopper can view and update cartrunCheckoutApplyCouponsTest
- Shopper can use coupons on checkoutrunCheckoutPageTest
- Shopper can complete checkoutrunMyAccountPageTest
- Shopper can access my account pagerunMyAccountPayOrderTest
- Shopper can pay for their order in My AccountrunProductBrowseSearchSortTest
- Shopper can browse, search & sort productsrunSingleProductPageTest
- Shopper can view single product page in many variations (simple, variable, grouped)runVariableProductUpdateTest
- Shopper can view and update variations on a variable productrunCheckoutCreateAccountTest
- Shopper can create an account during checkoutrunCheckoutLoginAccountTest
- Shopper can login to an account during checkoutrunMyAccountCreateAccountTest
- Shopper can create an account via my account pagerunCartCalculateShippingTest
- Shopper can calculate shipping in the cartrunCartRedirectionTest
- Shopper is redirected to the cart page after adding to cartrunOrderEmailReceivingTest
- Shopper can receive an email for his orderrunCartAndCheckoutConsistentShippingTest
- Shopper gets consistent shipping information on cart and checkout pages
REST API
runApiTests
- Run all API testsrunExternalProductAPITest
- Can create, read, and delete an external productrunGroupedProductAPITest
- Can create, read, and delete a grouped productrunVariableProductAPITest
- Can create, read, and delete a variable product and its variationsrunCouponApiTest
- Can create, read, and delete a couponrunOrderApiTest
- Can create, read, and delete an order
Contributing a new test
- In your branch create a new
example-test-name.test.js
under the appropriate folder in thespecs
directory. - 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
specs/index.js
const runExampleTestName = require( './grouping/example-test-name.test' );
// ...
module.exports = {
// ...
runExampleTestName,
}