Commit 9fe691e97f3 for woocommerce
commit 9fe691e97f3750ea3d23b2e4be6f029d294f85b1
Author: theAverageDev (Luca Tumedei) <luca.tumedei@automattic.com>
Date: Tue Mar 17 14:55:08 2026 +0100
Convert e2e-pw reporters, test-data, and data files to TypeScript (#63698)
* Rename reporters, test-data, and data files from .js to .ts
Mechanical rename only — no content changes. This preserves git history
by keeping renames separate from CJS-to-ESM conversion.
* Convert reporters, test-data, and data files from CJS to ESM TypeScript
- Convert require/module.exports to import/export in all 17 files
- Add minimal type annotations (reporter class properties, function params)
- Import TestCase/TestResult types from @playwright/test/reporter
- Update reporter string paths in playwright.config.js from .js to .ts
- Drop unused `variation` re-export from data barrel (was always undefined)
* Add changelog entry for e2e-pw reporters and data TypeScript conversion
* Fix linter errors in e2e-pw reporters and data TypeScript files
* Address CodeRabbit review feedback on e2e-pw data files
- Add runtime guards for resources and payload types in batch-update.ts
- Fix JSDoc type mismatch for methodId param in shipping-method.ts
- Fix misleading file header comment in settings.ts
- Replace any type with ShippingMethodExample interface in shipping-method.ts
* Fix JSDoc for getShippingMethodExample to match TypeScript contract
* Add ShippingMethodId union type for better IDE suggestions
---------
Co-authored-by: Alex López <45979455+alopezari@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/e2e-pw-ts-conversion-reporters-data b/plugins/woocommerce/changelog/e2e-pw-ts-conversion-reporters-data
new file mode 100644
index 00000000000..387a209f70b
--- /dev/null
+++ b/plugins/woocommerce/changelog/e2e-pw-ts-conversion-reporters-data
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Convert e2e-pw reporters, test-data, and data files from CJS to ESM TypeScript.
diff --git a/plugins/woocommerce/tests/e2e-pw/data/coupon.js b/plugins/woocommerce/tests/e2e-pw/data/coupon.ts
similarity index 92%
rename from plugins/woocommerce/tests/e2e-pw/data/coupon.js
rename to plugins/woocommerce/tests/e2e-pw/data/coupon.ts
index 6104d22448b..28c2c12365c 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/coupon.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/coupon.ts
@@ -6,7 +6,7 @@
* https://woocommerce.github.io/woocommerce-rest-api-docs/#coupons
*
*/
-const coupon = {
+export const coupon = {
code: '10off',
amount: '10',
discount_type: 'percent',
@@ -27,7 +27,3 @@ const coupon = {
maximum_amount: '',
email_restrictions: [],
};
-
-module.exports = {
- coupon,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/index.js b/plugins/woocommerce/tests/e2e-pw/data/index.js
deleted file mode 100644
index a9b8c214635..00000000000
--- a/plugins/woocommerce/tests/e2e-pw/data/index.js
+++ /dev/null
@@ -1,40 +0,0 @@
-const {
- order,
- getOrderExample,
- getOrderExampleSearchTest,
-} = require( './order' );
-const { coupon } = require( './coupon' );
-const { refund } = require( './refund' );
-const { getTaxRateExamples, allUSTaxesExample } = require( './tax-rate' );
-const { getVariationExample } = require( './variation' );
-const {
- simpleProduct,
- variableProduct,
- variation,
- virtualProduct,
- groupedProduct,
- externalProduct,
-} = require( './products-crud' );
-const { getShippingZoneExample } = require( './shipping-zone' );
-const { getShippingMethodExample } = require( './shipping-method' );
-const shared = require( './shared' );
-
-module.exports = {
- order,
- getOrderExample,
- getOrderExampleSearchTest,
- coupon,
- shared,
- refund,
- allUSTaxesExample,
- getTaxRateExamples,
- getVariationExample,
- simpleProduct,
- variableProduct,
- variation,
- virtualProduct,
- groupedProduct,
- externalProduct,
- getShippingZoneExample,
- getShippingMethodExample,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/index.ts b/plugins/woocommerce/tests/e2e-pw/data/index.ts
new file mode 100644
index 00000000000..c81d6121b7e
--- /dev/null
+++ b/plugins/woocommerce/tests/e2e-pw/data/index.ts
@@ -0,0 +1,37 @@
+/**
+ * Internal dependencies
+ */
+import { order, getOrderExample, getOrderExampleSearchTest } from './order';
+import { coupon } from './coupon';
+import { refund } from './refund';
+import { getTaxRateExamples, allUSTaxesExample } from './tax-rate';
+import { getVariationExample } from './variation';
+import {
+ simpleProduct,
+ variableProduct,
+ virtualProduct,
+ groupedProduct,
+ externalProduct,
+} from './products-crud';
+import { getShippingZoneExample } from './shipping-zone';
+import { getShippingMethodExample } from './shipping-method';
+import * as shared from './shared';
+
+export {
+ order,
+ getOrderExample,
+ getOrderExampleSearchTest,
+ coupon,
+ shared,
+ refund,
+ allUSTaxesExample,
+ getTaxRateExamples,
+ getVariationExample,
+ simpleProduct,
+ variableProduct,
+ virtualProduct,
+ groupedProduct,
+ externalProduct,
+ getShippingZoneExample,
+ getShippingMethodExample,
+};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/order.js b/plugins/woocommerce/tests/e2e-pw/data/order.ts
similarity index 84%
rename from plugins/woocommerce/tests/e2e-pw/data/order.js
rename to plugins/woocommerce/tests/e2e-pw/data/order.ts
index 64ffbe26d75..47f2fd88b48 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/order.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/order.ts
@@ -1,8 +1,11 @@
-const { customerBilling, customerShipping } = require( './shared' );
-const {
+/**
+ * Internal dependencies
+ */
+import { customerBilling, customerShipping } from './shared';
+import {
customerBillingSearchTest,
customerShippingSearchTest,
-} = require( './shared/customer' );
+} from './shared/customer';
/**
* A basic order.
@@ -11,7 +14,7 @@ const {
*
* https://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties
*/
-const order = {
+export const order = {
payment_method: '',
payment_method_title: '',
status: 'pending',
@@ -59,7 +62,7 @@ const couponLines = {
*
* @return {Object} Sample Order payload.
*/
-const getOrderExample = () => {
+export const getOrderExample = () => {
const orderExample = {
id: 0,
payment_method: 'cod',
@@ -79,7 +82,7 @@ const getOrderExample = () => {
return orderExample;
};
-const getOrderExampleSearchTest = () => {
+export const getOrderExampleSearchTest = () => {
const orderExampleSearchTest = {
id: 0,
payment_method: 'cod',
@@ -98,13 +101,3 @@ const getOrderExampleSearchTest = () => {
};
return orderExampleSearchTest;
};
-
-module.exports = {
- order,
- productLineItems,
- shippingLines,
- feeLines,
- couponLines,
- getOrderExample,
- getOrderExampleSearchTest,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/products-crud.js b/plugins/woocommerce/tests/e2e-pw/data/products-crud.ts
similarity index 83%
rename from plugins/woocommerce/tests/e2e-pw/data/products-crud.js
rename to plugins/woocommerce/tests/e2e-pw/data/products-crud.ts
index 18cb8e076cf..57d1ecc063b 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/products-crud.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/products-crud.ts
@@ -10,7 +10,7 @@
/**
* A simple, physical product.
*/
-const simpleProduct = {
+export const simpleProduct = {
name: 'A Simple Product',
regular_price: '25',
description: 'Description for this simple product.',
@@ -20,7 +20,7 @@ const simpleProduct = {
/**
* A virtual product
*/
-const virtualProduct = {
+export const virtualProduct = {
name: 'A Virtual Product',
regular_price: '10',
virtual: true,
@@ -29,7 +29,7 @@ const virtualProduct = {
/**
* A variable product
*/
-const variableProduct = {
+export const variableProduct = {
name: 'A Variable Product',
type: 'variable',
attributes: [
@@ -57,7 +57,7 @@ const variableProduct = {
/**
* External product example
*/
-const externalProduct = {
+export const externalProduct = {
name: 'An External Product',
regular_price: '1.00',
type: 'external',
@@ -66,15 +66,7 @@ const externalProduct = {
/**
* Grouped product example
*/
-const groupedProduct = {
+export const groupedProduct = {
name: 'A Grouped Product',
type: 'grouped',
};
-
-module.exports = {
- simpleProduct,
- virtualProduct,
- variableProduct,
- externalProduct,
- groupedProduct,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/refund.js b/plugins/woocommerce/tests/e2e-pw/data/refund.ts
similarity index 84%
rename from plugins/woocommerce/tests/e2e-pw/data/refund.js
rename to plugins/woocommerce/tests/e2e-pw/data/refund.ts
index 953df08b4f4..07e57e1a9a7 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/refund.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/refund.ts
@@ -6,13 +6,9 @@
* https://woocommerce.github.io/woocommerce-rest-api-docs/#order-refund-properties
*
*/
-const refund = {
+export const refund = {
api_refund: false,
amount: '1.00',
reason: 'Late delivery refund.',
line_items: [],
};
-
-module.exports = {
- refund,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/settings.js b/plugins/woocommerce/tests/e2e-pw/data/settings.ts
similarity index 99%
rename from plugins/woocommerce/tests/e2e-pw/data/settings.js
rename to plugins/woocommerce/tests/e2e-pw/data/settings.ts
index 3127f8efec8..fb50470c015 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/settings.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/settings.ts
@@ -1,13 +1,13 @@
/**
- * Default shipping zone object.
+ * Settings data for currencies, countries, and state options.
*
- * For more details on shipping zone properties, see:
+ * For more details on settings properties, see:
*
- * https://woocommerce.github.io/woocommerce-rest-api-docs/#shipping-zone-properties
+ * https://woocommerce.github.io/woocommerce-rest-api-docs/#settings
*
*/
-const currencies = {
+export const currencies = {
AED: 'United Arab Emirates dirham (د.إ) — AED',
AFN: 'Afghan afghani (؋) — AFN',
ALL: 'Albanian lek (L) — ALL',
@@ -172,7 +172,7 @@ const currencies = {
ZMW: 'Zambian kwacha (ZK) — ZMW',
};
-const externalCurrencies = {
+export const externalCurrencies = {
AED: 'United Arab Emirates dirham (د.إ)',
AFN: 'Afghan afghani (؋)',
ALL: 'Albanian lek (L)',
@@ -337,7 +337,7 @@ const externalCurrencies = {
ZMW: 'Zambian kwacha (ZK)',
};
-const stateOptions = {
+export const stateOptions = {
AF: 'Afghanistan',
AX: 'Åland Islands',
'AL:AL-01': 'Albania - Berat',
@@ -2492,7 +2492,7 @@ const stateOptions = {
ZW: 'Zimbabwe',
};
-const countries = {
+export const countries = {
AF: 'Afghanistan',
AX: 'Åland Islands',
AL: 'Albania',
@@ -2743,7 +2743,7 @@ const countries = {
ZW: 'Zimbabwe',
};
-const externalCountries = {
+export const externalCountries = {
AF: 'Afghanistan',
AX: 'Åland Islands',
AL: 'Albania',
@@ -2994,11 +2994,3 @@ const externalCountries = {
ZM: 'Zambia',
ZW: 'Zimbabwe',
};
-
-module.exports = {
- countries,
- currencies,
- externalCurrencies,
- externalCountries,
- stateOptions,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/shared/batch-update.js b/plugins/woocommerce/tests/e2e-pw/data/shared/batch-update.ts
similarity index 77%
rename from plugins/woocommerce/tests/e2e-pw/data/shared/batch-update.js
rename to plugins/woocommerce/tests/e2e-pw/data/shared/batch-update.ts
index 700943d0d68..904c5afac9b 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/shared/batch-update.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/shared/batch-update.ts
@@ -7,7 +7,23 @@
* @param {Array} resources A list of resource objects. For the delete action, this will be a list of IDs.
* @param {Object} payload The batch payload object. Defaults to an empty object.
*/
-const batch = ( action, resources = [], payload = {} ) => {
+export const batch = (
+ action: string,
+ resources: any[] = [],
+ payload: any = {}
+) => {
+ if ( ! Array.isArray( resources ) ) {
+ return;
+ }
+
+ if (
+ payload === null ||
+ typeof payload !== 'object' ||
+ Array.isArray( payload )
+ ) {
+ return;
+ }
+
if ( ! [ 'create', 'update', 'delete' ].includes( action ) ) {
return;
}
@@ -31,15 +47,10 @@ const batch = ( action, resources = [], payload = {} ) => {
return payload;
};
-const getBatchPayloadExample = ( resource ) => {
+export const getBatchPayloadExample = ( resource: any ) => {
let batchUpdatePayload = {};
batchUpdatePayload = batch( 'create', [ resource ], batchUpdatePayload );
batchUpdatePayload = batch( 'update', [ resource ], batchUpdatePayload );
batchUpdatePayload = batch( 'delete', [ 1, 2, 3 ], batchUpdatePayload );
return batchUpdatePayload;
};
-
-module.exports = {
- batch,
- getBatchPayloadExample,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/shared/customer.js b/plugins/woocommerce/tests/e2e-pw/data/shared/customer.ts
similarity index 85%
rename from plugins/woocommerce/tests/e2e-pw/data/shared/customer.js
rename to plugins/woocommerce/tests/e2e-pw/data/shared/customer.ts
index c30e320b61e..04890975356 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/shared/customer.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/shared/customer.ts
@@ -5,7 +5,7 @@
* https://woocommerce.github.io/woocommerce-rest-api-docs/#customers
* https://woocommerce.github.io/woocommerce-rest-api-docs/#orders
*/
-const customerBilling = {
+export const customerBilling = {
first_name: 'John',
last_name: 'Doe',
company: 'Automattic',
@@ -19,7 +19,7 @@ const customerBilling = {
email: 'john.doe@example.com',
};
-const customerBillingSearchTest = {
+export const customerBillingSearchTest = {
first_name: 'Johnsearch',
last_name: 'Doesearch',
company: 'Automatticsearch',
@@ -40,7 +40,7 @@ const customerBillingSearchTest = {
* https://woocommerce.github.io/woocommerce-rest-api-docs/#customers
* https://woocommerce.github.io/woocommerce-rest-api-docs/#orders
*/
-const customerShipping = {
+export const customerShipping = {
first_name: 'Tim',
last_name: 'Clark',
company: 'Automattic',
@@ -53,7 +53,7 @@ const customerShipping = {
phone: '123456789',
};
-const customerShippingSearchTest = {
+export const customerShippingSearchTest = {
first_name: 'Timsearch',
last_name: 'Clarksearch',
company: 'Automatticsearch',
@@ -65,10 +65,3 @@ const customerShippingSearchTest = {
postcode: '14201search',
phone: '123456789search',
};
-
-module.exports = {
- customerBilling,
- customerBillingSearchTest,
- customerShipping,
- customerShippingSearchTest,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/shared/error-response.js b/plugins/woocommerce/tests/e2e-pw/data/shared/error-response.ts
similarity index 72%
rename from plugins/woocommerce/tests/e2e-pw/data/shared/error-response.js
rename to plugins/woocommerce/tests/e2e-pw/data/shared/error-response.ts
index f77b36334ac..3ea957b24ff 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/shared/error-response.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/shared/error-response.ts
@@ -3,12 +3,10 @@
*
* https://woocommerce.github.io/woocommerce-rest-api-docs/#errors
*/
-const errorResponse = {
+export const errorResponse = {
code: '',
message: '',
data: {
status: 400,
},
};
-
-module.exports = { errorResponse };
diff --git a/plugins/woocommerce/tests/e2e-pw/data/shared/index.js b/plugins/woocommerce/tests/e2e-pw/data/shared/index.js
deleted file mode 100644
index 033b5183b17..00000000000
--- a/plugins/woocommerce/tests/e2e-pw/data/shared/index.js
+++ /dev/null
@@ -1,11 +0,0 @@
-const { customerBilling, customerShipping } = require( './customer' );
-const { batch, getBatchPayloadExample } = require( './batch-update' );
-const { errorResponse } = require( './error-response' );
-
-module.exports = {
- customerBilling,
- customerShipping,
- batch,
- getBatchPayloadExample,
- errorResponse,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/shared/index.ts b/plugins/woocommerce/tests/e2e-pw/data/shared/index.ts
new file mode 100644
index 00000000000..2c130ffcc2a
--- /dev/null
+++ b/plugins/woocommerce/tests/e2e-pw/data/shared/index.ts
@@ -0,0 +1,14 @@
+/**
+ * Internal dependencies
+ */
+import { customerBilling, customerShipping } from './customer';
+import { batch, getBatchPayloadExample } from './batch-update';
+import { errorResponse } from './error-response';
+
+export {
+ customerBilling,
+ customerShipping,
+ batch,
+ getBatchPayloadExample,
+ errorResponse,
+};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/shipping-method.js b/plugins/woocommerce/tests/e2e-pw/data/shipping-method.js
deleted file mode 100644
index e972274927b..00000000000
--- a/plugins/woocommerce/tests/e2e-pw/data/shipping-method.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Constructs a shipping method based on the given `methodId` and `cost`.
- *
- * `methodId` should be one of the following:
- * - `free_shipping`
- * - `flat_rate`
- * - `local_pickup`
- *
- * @param {number} methodId
- * @param {number} cost
- * @return {Object} shipping method object that can serve as a request payload for adding a shipping method to a shipping zone.
- */
-const getShippingMethodExample = ( methodId, cost ) => {
- const shippingMethodExample = {
- method_id: methodId,
- };
-
- if ( cost !== undefined ) {
- shippingMethodExample.settings = {
- cost,
- };
- }
-
- return shippingMethodExample;
-};
-
-module.exports = {
- getShippingMethodExample,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/shipping-method.ts b/plugins/woocommerce/tests/e2e-pw/data/shipping-method.ts
new file mode 100644
index 00000000000..7882da3f2e0
--- /dev/null
+++ b/plugins/woocommerce/tests/e2e-pw/data/shipping-method.ts
@@ -0,0 +1,30 @@
+/**
+ * Constructs a shipping method based on the given `methodId` and `cost`.
+ *
+ * @param {ShippingMethodId} methodId
+ * @param {number=} cost
+ * @return {ShippingMethodExample} Shipping method object that can serve as a request payload for adding a shipping method to a shipping zone.
+ */
+type ShippingMethodId = 'free_shipping' | 'flat_rate' | 'local_pickup';
+
+interface ShippingMethodExample {
+ method_id: ShippingMethodId;
+ settings?: { cost: number };
+}
+
+export const getShippingMethodExample = (
+ methodId: ShippingMethodId,
+ cost?: number
+) => {
+ const shippingMethodExample: ShippingMethodExample = {
+ method_id: methodId,
+ };
+
+ if ( cost !== undefined ) {
+ shippingMethodExample.settings = {
+ cost,
+ };
+ }
+
+ return shippingMethodExample;
+};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/shipping-zone.js b/plugins/woocommerce/tests/e2e-pw/data/shipping-zone.ts
similarity index 78%
rename from plugins/woocommerce/tests/e2e-pw/data/shipping-zone.js
rename to plugins/woocommerce/tests/e2e-pw/data/shipping-zone.ts
index fb88e9d8596..0d79e95cbc1 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/shipping-zone.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/shipping-zone.ts
@@ -14,10 +14,6 @@ const shippingZone = {
* Constructs a default shipping zone object.
*
*/
-const getShippingZoneExample = () => {
+export const getShippingZoneExample = () => {
return shippingZone;
};
-
-module.exports = {
- getShippingZoneExample,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/tax-rate.js b/plugins/woocommerce/tests/e2e-pw/data/tax-rate.ts
similarity index 97%
rename from plugins/woocommerce/tests/e2e-pw/data/tax-rate.js
rename to plugins/woocommerce/tests/e2e-pw/data/tax-rate.ts
index 50fa2b7cfd7..f4af574ae5a 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/tax-rate.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/tax-rate.ts
@@ -24,11 +24,11 @@ const zeroTaxRate = {
class: 'zero-rate',
};
-const getTaxRateExamples = () => {
+export const getTaxRateExamples = () => {
return { standardTaxRate, reducedTaxRate, zeroTaxRate };
};
-const allUSTaxesExample = [
+export const allUSTaxesExample = [
{
country: 'US',
state: 'AL',
@@ -414,8 +414,3 @@ const allUSTaxesExample = [
order: 48,
},
];
-
-module.exports = {
- getTaxRateExamples,
- allUSTaxesExample,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/data/variation.js b/plugins/woocommerce/tests/e2e-pw/data/variation.ts
similarity index 82%
rename from plugins/woocommerce/tests/e2e-pw/data/variation.js
rename to plugins/woocommerce/tests/e2e-pw/data/variation.ts
index 465a71248b0..24abae7c8e4 100644
--- a/plugins/woocommerce/tests/e2e-pw/data/variation.js
+++ b/plugins/woocommerce/tests/e2e-pw/data/variation.ts
@@ -20,10 +20,6 @@ const variation = {
],
};
-const getVariationExample = () => {
+export const getVariationExample = () => {
return variation;
};
-
-module.exports = {
- getVariationExample,
-};
diff --git a/plugins/woocommerce/tests/e2e-pw/playwright.config.js b/plugins/woocommerce/tests/e2e-pw/playwright.config.js
index f63a309e7d4..1ec8dfb15cd 100644
--- a/plugins/woocommerce/tests/e2e-pw/playwright.config.js
+++ b/plugins/woocommerce/tests/e2e-pw/playwright.config.js
@@ -50,14 +50,14 @@ const reporter = [
},
],
[
- `${ TESTS_ROOT_PATH }/reporters/environment-reporter.js`,
+ `${ TESTS_ROOT_PATH }/reporters/environment-reporter.ts`,
{ outputFolder: `${ TESTS_ROOT_PATH }/test-results/allure-results` },
],
];
if ( process.env.CI ) {
reporter.push( [ 'buildkite-test-collector/playwright/reporter' ] );
- reporter.push( [ `${ TESTS_ROOT_PATH }/reporters/skipped-tests.js` ] );
+ reporter.push( [ `${ TESTS_ROOT_PATH }/reporters/skipped-tests.ts` ] );
reporter.push( [
'junit',
{
diff --git a/plugins/woocommerce/tests/e2e-pw/reporters/environment-reporter.js b/plugins/woocommerce/tests/e2e-pw/reporters/environment-reporter.ts
similarity index 80%
rename from plugins/woocommerce/tests/e2e-pw/reporters/environment-reporter.js
rename to plugins/woocommerce/tests/e2e-pw/reporters/environment-reporter.ts
index c07a7c9a623..2bfd9abd3a6 100644
--- a/plugins/woocommerce/tests/e2e-pw/reporters/environment-reporter.js
+++ b/plugins/woocommerce/tests/e2e-pw/reporters/environment-reporter.ts
@@ -1,11 +1,19 @@
-require( '@playwright/test/reporter' );
-const { request } = require( '@playwright/test' );
-const fs = require( 'fs' );
-const path = require( 'path' );
-const { admin } = require( '../test-data/data' );
+/**
+ * External dependencies
+ */
+import { request } from '@playwright/test';
+import fs from 'fs';
+import path from 'path';
+
+/**
+ * Internal dependencies
+ */
+import { admin } from '../test-data/data';
class EnvironmentReporter {
- constructor( options ) {
+ reportOptions: { outputFolder?: string };
+
+ constructor( options: { outputFolder?: string } ) {
this.reportOptions = options;
}
@@ -62,4 +70,4 @@ class EnvironmentReporter {
}
}
-module.exports = EnvironmentReporter;
+export default EnvironmentReporter;
diff --git a/plugins/woocommerce/tests/e2e-pw/reporters/skipped-tests.js b/plugins/woocommerce/tests/e2e-pw/reporters/skipped-tests.ts
similarity index 73%
rename from plugins/woocommerce/tests/e2e-pw/reporters/skipped-tests.js
rename to plugins/woocommerce/tests/e2e-pw/reporters/skipped-tests.ts
index 5ffd2df39e9..3ee93b443ba 100644
--- a/plugins/woocommerce/tests/e2e-pw/reporters/skipped-tests.js
+++ b/plugins/woocommerce/tests/e2e-pw/reporters/skipped-tests.ts
@@ -1,11 +1,16 @@
-require( '@playwright/test/reporter' );
+/**
+ * External dependencies
+ */
+import type { TestCase, TestResult } from '@playwright/test/reporter';
class SkippedReporter {
+ skippedTests: string[];
+
constructor() {
this.skippedTests = [];
}
- onTestEnd( testCase, testResult ) {
+ onTestEnd( testCase: TestCase, testResult: TestResult ) {
if (
testResult.status === 'skipped' &&
! testCase.location.file.includes( 'fixtures' )
@@ -27,4 +32,4 @@ class SkippedReporter {
}
}
-module.exports = SkippedReporter;
+export default SkippedReporter;
diff --git a/plugins/woocommerce/tests/e2e-pw/test-data/data.js b/plugins/woocommerce/tests/e2e-pw/test-data/data.ts
similarity index 96%
rename from plugins/woocommerce/tests/e2e-pw/test-data/data.js
rename to plugins/woocommerce/tests/e2e-pw/test-data/data.ts
index 6f4566809da..f628b8f658d 100644
--- a/plugins/woocommerce/tests/e2e-pw/test-data/data.js
+++ b/plugins/woocommerce/tests/e2e-pw/test-data/data.ts
@@ -10,7 +10,7 @@ const {
USE_WP_ENV,
} = process.env;
-const admin = {
+export const admin = {
username: ADMIN_USER ?? 'admin',
password: ADMIN_PASSWORD ?? 'password',
email:
@@ -20,7 +20,7 @@ const admin = {
: 'admin@woocommercecoree2etestsuite.com' ),
};
-const customer = {
+export const customer = {
username: CUSTOMER_USER ?? 'customer',
password: CUSTOMER_PASSWORD ?? 'password',
email: CUSTOMER_USER_EMAIL ?? 'customer@woocommercecoree2etestsuite.com',
@@ -51,7 +51,7 @@ const customer = {
},
};
-const storeDetails = {
+export const storeDetails = {
us: {
store: {
address: 'addr1',
@@ -114,9 +114,3 @@ const storeDetails = {
},
},
};
-
-module.exports = {
- storeDetails,
- admin,
- customer,
-};