From 85485513e2fcd5fcc7323ec8c4daff03d9cbae4e Mon Sep 17 00:00:00 2001 From: Tomasz Tunik Date: Fri, 1 Apr 2022 10:22:54 +0200 Subject: [PATCH] Ensure e2e tests work with TS (#6173) * Cleanup e2e jest config from moduleFileExtensions moduleFileExtensions by default support js, ts, tsx etc. * convert legacy-template-blocks e2e test to TS * clean up jest.config.json moduleFileExtensions unnecessary defaults override --- tests/e2e/config/jest.config.js | 3 --- ...-blocks.test.js => legacy-template-blocks.test.ts} | 11 ++++++++--- tests/js/jest.config.json | 3 +-- 3 files changed, 9 insertions(+), 8 deletions(-) rename tests/e2e/specs/frontend/{legacy-template-blocks.test.js => legacy-template-blocks.test.ts} (95%) diff --git a/tests/e2e/config/jest.config.js b/tests/e2e/config/jest.config.js index 6dbc7ada5d9..a410a07a9b8 100644 --- a/tests/e2e/config/jest.config.js +++ b/tests/e2e/config/jest.config.js @@ -4,9 +4,6 @@ module.exports = { // Automatically clear mock calls and instances between every test clearMocks: true, - // An array of file extensions your modules use - moduleFileExtensions: [ 'js', 'ts' ], - moduleNameMapper: { '@woocommerce/blocks-test-utils': '/tests/utils', }, diff --git a/tests/e2e/specs/frontend/legacy-template-blocks.test.js b/tests/e2e/specs/frontend/legacy-template-blocks.test.ts similarity index 95% rename from tests/e2e/specs/frontend/legacy-template-blocks.test.js rename to tests/e2e/specs/frontend/legacy-template-blocks.test.ts index 47553496c95..584992d2816 100644 --- a/tests/e2e/specs/frontend/legacy-template-blocks.test.js +++ b/tests/e2e/specs/frontend/legacy-template-blocks.test.ts @@ -41,7 +41,9 @@ describe( 'Classic Template blocks', () => { it( 'renders a list of products with their count and pagination', async () => { const { productArchivePage } = SELECTORS; - await page.goto( new URL( '/?post_type=product', BASE_URL ) ); + await page.goto( + new URL( '/?post_type=product', BASE_URL ).toString() + ); await page.waitForSelector( productArchivePage.productsList ); await page.waitForSelector( productArchivePage.resultsCount ); @@ -74,7 +76,7 @@ describe( 'Classic Template blocks', () => { new URL( `/product-category/${ CATEGORY_NAME.toLowerCase() }`, BASE_URL - ) + ).toString() ); await expect( page ).toMatchElement( productArchivePage.title, { @@ -109,7 +111,10 @@ describe( 'Classic Template blocks', () => { const { productArchivePage } = SELECTORS; await page.goto( - new URL( `/product-tag/${ TAG_NAME.toLowerCase() }`, BASE_URL ) + new URL( + `/product-tag/${ TAG_NAME.toLowerCase() }`, + BASE_URL + ).toString() ); await expect( page ).toMatchElement( productArchivePage.title, { diff --git a/tests/js/jest.config.json b/tests/js/jest.config.json index 1e65f1732f8..409b159f2a2 100644 --- a/tests/js/jest.config.json +++ b/tests/js/jest.config.json @@ -50,6 +50,5 @@ "transform": { "^.+\\.(js|ts|tsx)$": "/tests/js/jestPreprocess.js" }, - "verbose": true, - "moduleFileExtensions": [ "js", "jsx", "ts", "tsx", "json", "node" ] + "verbose": true }