From df3588cac943ae7c67f1258494bb3708c6f84d12 Mon Sep 17 00:00:00 2001 From: Sub <9058689+zubhav@users.noreply.github.com> Date: Thu, 5 May 2022 09:07:24 +0100 Subject: [PATCH 1/4] fix silent failing test --- packages/cli/tests/watch.test.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/cli/tests/watch.test.js b/packages/cli/tests/watch.test.js index 49143d9ed..3dab0f5bd 100644 --- a/packages/cli/tests/watch.test.js +++ b/packages/cli/tests/watch.test.js @@ -89,7 +89,7 @@ describe('should determine the correct port', () => { expect(await determinePort('3999')).toBe(3999); }); - it('should use $PORT in the abscence of --port', async () => { + it('should use $PORT in the absence of --port', async () => { process.env.PORT = '4001'; expect(await determinePort()).toBe(4001); }); @@ -105,14 +105,10 @@ describe('should determine the correct port', () => { }); it('should return an error if requested --port is taken', async () => { - await Promise.all([determinePort(4003), determinePort(4003)]).catch( - error => { - expect(error.message).toMatch( - new RegExp( - /^Another process is already running on port 4003. Please choose a different port./g - ) - ); - } + expect( + Promise.all([determinePort(4003), determinePort(4003)]) + ).rejects.toThrow( + 'Another process is already running on port 4003. Please choose a different port.' ); }); From fd19482ad6931d171ab7c78eef9a8713154e3a7d Mon Sep 17 00:00:00 2001 From: Sub <9058689+zubhav@users.noreply.github.com> Date: Mon, 9 May 2022 11:32:28 +0100 Subject: [PATCH 2/4] remove lint warnings, update tests and rename file --- packages/cli/babel/index.js | 4 +++- packages/cli/sw/{contants.js => constants.js} | 0 packages/cli/sw/index.js | 2 +- packages/cli/tests/build.test.js | 4 +++- packages/cli/tests/lib/chrome.js | 2 +- packages/cli/tests/lib/output.js | 2 +- packages/cli/tests/subjects/custom-dotenv/index.js | 2 +- 7 files changed, 10 insertions(+), 6 deletions(-) rename packages/cli/sw/{contants.js => constants.js} (100%) diff --git a/packages/cli/babel/index.js b/packages/cli/babel/index.js index 6d54506f8..0611536dd 100644 --- a/packages/cli/babel/index.js +++ b/packages/cli/babel/index.js @@ -1,3 +1,5 @@ +// Is this file used/required? If not, can it be removed? + var isProd = (process.env.BABEL_ENV || process.env.NODE_ENV) === 'production'; /** * test env detection is used to default mode for @@ -21,7 +23,7 @@ var defaultBrowserListDev = [ 'ios_saf >= 10.3', 'edge >= 16', 'opera >= 48', - 'samsung >= 8.2' + 'samsung >= 8.2', ]; // preact-cli babel configs diff --git a/packages/cli/sw/contants.js b/packages/cli/sw/constants.js similarity index 100% rename from packages/cli/sw/contants.js rename to packages/cli/sw/constants.js diff --git a/packages/cli/sw/index.js b/packages/cli/sw/index.js index 52259f9ae..da325d51f 100644 --- a/packages/cli/sw/index.js +++ b/packages/cli/sw/index.js @@ -1,7 +1,7 @@ import { registerRoute, setCatchHandler } from 'workbox-routing'; import { precacheAndRoute, getCacheKeyForURL } from 'workbox-precaching'; import { isNav } from './utils'; -import { NETWORK_HANDLER, PRECACHING_OPTIONS } from './contants'; +import { NETWORK_HANDLER, PRECACHING_OPTIONS } from './constants'; export function getFiles() { return self.__WB_MANIFEST; diff --git a/packages/cli/tests/build.test.js b/packages/cli/tests/build.test.js index a2be5370b..81f54281f 100644 --- a/packages/cli/tests/build.test.js +++ b/packages/cli/tests/build.test.js @@ -182,8 +182,10 @@ describe('preact build', () => { `${dir}/build/${bundleFile}`, 'utf8' ); + // "Hello World!" should replace 'process.env.PREACT_APP_MY_VARIABLE' - expect(transpiledChunk.includes('console.log("Hello World!")')).toBe(true); + expect(transpiledChunk.includes('Hello World!')).toBe(true); + expect(transpiledChunk.includes('PREACT_APP_MY_VARIABLE')).toBe(false); }); it('should respect `publicPath` value', async () => { diff --git a/packages/cli/tests/lib/chrome.js b/packages/cli/tests/lib/chrome.js index 1f9d34f9c..78230c37e 100644 --- a/packages/cli/tests/lib/chrome.js +++ b/packages/cli/tests/lib/chrome.js @@ -12,7 +12,7 @@ module.exports.waitUntilExpression = async function (page, expression) { `Waiting for ${expression}` ); - return result; // && result.value; + return result; }; await waitUntil(evaluate, `Waiting for ${expression} timed out!`); diff --git a/packages/cli/tests/lib/output.js b/packages/cli/tests/lib/output.js index ef06c185b..095054dbc 100644 --- a/packages/cli/tests/lib/output.js +++ b/packages/cli/tests/lib/output.js @@ -10,7 +10,7 @@ async function tmpDir() { let str = Math.random() .toString(36) .replace(/[^a-z]+/g, '') - .substr(0, 12); + .substring(0, 12); await mkdir(output, { recursive: true }); return resolve(output, str); } diff --git a/packages/cli/tests/subjects/custom-dotenv/index.js b/packages/cli/tests/subjects/custom-dotenv/index.js index 9e532391e..2681c31c6 100644 --- a/packages/cli/tests/subjects/custom-dotenv/index.js +++ b/packages/cli/tests/subjects/custom-dotenv/index.js @@ -1 +1 @@ -console.log(process.env.PREACT_APP_MY_VARIABLE); +export const MY_VARIABLE = process.env.PREACT_APP_MY_VARIABLE; From 6b20af0e18e683c5e54fc1167e3ba9dfb05d38db Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Mon, 9 May 2022 16:49:28 -0500 Subject: [PATCH 3/4] Update packages/cli/tests/build.test.js --- packages/cli/tests/build.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/tests/build.test.js b/packages/cli/tests/build.test.js index 81f54281f..0f49700e3 100644 --- a/packages/cli/tests/build.test.js +++ b/packages/cli/tests/build.test.js @@ -184,7 +184,7 @@ describe('preact build', () => { ); // "Hello World!" should replace 'process.env.PREACT_APP_MY_VARIABLE' - expect(transpiledChunk.includes('Hello World!')).toBe(true); + expect(transpiledChunk.includes('"Hello World!"')).toBe(true); expect(transpiledChunk.includes('PREACT_APP_MY_VARIABLE')).toBe(false); }); From f24fd939c2f137d1c0c54301614e1bd77c2053d1 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Mon, 9 May 2022 16:49:34 -0500 Subject: [PATCH 4/4] Update packages/cli/babel/index.js --- packages/cli/babel/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/cli/babel/index.js b/packages/cli/babel/index.js index 0611536dd..6fff82da7 100644 --- a/packages/cli/babel/index.js +++ b/packages/cli/babel/index.js @@ -1,5 +1,3 @@ -// Is this file used/required? If not, can it be removed? - var isProd = (process.env.BABEL_ENV || process.env.NODE_ENV) === 'production'; /** * test env detection is used to default mode for