Skip to content

Commit

Permalink
fix: unstable els tests (#4805)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent authored Jan 29, 2025
1 parent af8ddac commit 9a2a4a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
10 changes: 5 additions & 5 deletions lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,18 @@ class Container {
* @param {Object<string, *>} newSupport
* @param {Object<string, *>} 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<void>}
*/
static async started(fn = null) {
Expand Down
11 changes: 2 additions & 9 deletions test/unit/els_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})

Expand All @@ -51,7 +49,7 @@ describe('els', function () {
let elementUsed

await els.element('.selector', async el => {
elementUsed = el
elementUsed = await el
})

assert.equal(elementUsed, 'el1')
Expand All @@ -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()
Expand Down Expand Up @@ -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')
Expand All @@ -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)')
Expand All @@ -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)')
Expand All @@ -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)')
Expand Down

0 comments on commit 9a2a4a0

Please sign in to comment.