From 9a2a4a04fb87e81452e71878836c1d505ff3625d Mon Sep 17 00:00:00 2001 From: kobenguyent <7845001+kobenguyent@users.noreply.github.com> Date: Wed, 29 Jan 2025 03:58:10 +0100 Subject: [PATCH] fix: unstable els tests (#4805) --- lib/container.js | 10 +++++----- test/unit/els_test.js | 11 ++--------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/container.js b/lib/container.js index 6a041bb14..e2913bd3d 100644 --- a/lib/container.js +++ b/lib/container.js @@ -162,18 +162,18 @@ class Container { * @param {Object} newSupport * @param {Object} newPlugins */ - static clear(newHelpers, newSupport, newPlugins) { - container.helpers = newHelpers || {} + static clear(newHelpers = {}, newSupport = {}, newPlugins = {}) { + container.helpers = newHelpers container.translation = loadTranslation() - container.proxySupport = createSupportObjects(newSupport || {}) - container.plugins = newPlugins || {} + container.proxySupport = createSupportObjects(newSupport) + container.plugins = newPlugins asyncHelperPromise = Promise.resolve() store.actor = null debug('container cleared') } /** - * @param {Function} fn + * @param {Function|null} fn * @returns {Promise} */ static async started(fn = null) { diff --git a/test/unit/els_test.js b/test/unit/els_test.js index 09f2081c0..a8d46896a 100644 --- a/test/unit/els_test.js +++ b/test/unit/els_test.js @@ -38,11 +38,9 @@ describe('els', function () { let elementUsed await els.element('my test', '.selector', async el => { - elementUsed = el + elementUsed = await el }) - await recorder.promise() - assert.equal(elementUsed, 'el1') }) @@ -51,7 +49,7 @@ describe('els', function () { let elementUsed await els.element('.selector', async el => { - elementUsed = el + elementUsed = await el }) assert.equal(elementUsed, 'el1') @@ -77,7 +75,6 @@ describe('els', function () { }, new StepConfig().timeout(0.01), ) - await recorder.promise() throw new Error('should have thrown error') } catch (e) { recorder.catch() @@ -147,7 +144,6 @@ describe('els', function () { await els.eachElement('.selector', async el => { throw new Error(`failed on ${el}`) }) - await recorder.promise() throw new Error('should have thrown error') } catch (e) { expect(e.message).to.equal('failed on el1') @@ -167,7 +163,6 @@ describe('els', function () { try { await els.expectElement('.selector', async () => false) - await recorder.promise() throw new Error('should have thrown error') } catch (e) { expect(e.cliMessage()).to.include('element (.selector)') @@ -187,7 +182,6 @@ describe('els', function () { try { await els.expectAnyElement('.selector', async () => false) - await recorder.promise() throw new Error('should have thrown error') } catch (e) { expect(e.cliMessage()).to.include('any element of (.selector)') @@ -207,7 +201,6 @@ describe('els', function () { try { await els.expectAllElements('.selector', async el => el !== 'el2') - await recorder.promise() throw new Error('should have thrown error') } catch (e) { expect(e.cliMessage()).to.include('element #2 of (.selector)')