Automattic / woocommerce-services

WooCommerce Services is a feature plugin that integrates hosted services into WooCommerce (3.0+), and currently includes automated tax rates and the ability to purchase and print USPS shipping labels.
GNU General Public License v2.0
105 stars 20 forks source link

API mocking for E2E tests modifies production code #1898

Open c-shultz opened 4 years ago

c-shultz commented 4 years ago

Ideally, our test code would not need to touch the production code, but there's a flag check here to load the mocked API client:

https://github.com/Automattic/woocommerce-services/blob/6aa66d4f8087e15af19cba5026a6809e80c491a0/woocommerce-services.php#L645-L651

c-shultz commented 4 years ago

One approach that was discussed at our dev roundtable was to mock the connect server. This node-based mock REST server let's you define endpoints/responses with a JSON file: https://github.com/typicode/json-server. That may be a good one since we're already defining our mock responses in a JSON file.

c-shultz commented 4 years ago

I'm bumping this out of the milestone. It's a lower priority and we'll look at addressing it in the future.