Skip to content

Commit 9a2a4a0

Browse files
authored
fix: unstable els tests (#4805)
1 parent af8ddac commit 9a2a4a0

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

lib/container.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,18 @@ class Container {
162162
* @param {Object<string, *>} newSupport
163163
* @param {Object<string, *>} newPlugins
164164
*/
165-
static clear(newHelpers, newSupport, newPlugins) {
166-
container.helpers = newHelpers || {}
165+
static clear(newHelpers = {}, newSupport = {}, newPlugins = {}) {
166+
container.helpers = newHelpers
167167
container.translation = loadTranslation()
168-
container.proxySupport = createSupportObjects(newSupport || {})
169-
container.plugins = newPlugins || {}
168+
container.proxySupport = createSupportObjects(newSupport)
169+
container.plugins = newPlugins
170170
asyncHelperPromise = Promise.resolve()
171171
store.actor = null
172172
debug('container cleared')
173173
}
174174

175175
/**
176-
* @param {Function} fn
176+
* @param {Function|null} fn
177177
* @returns {Promise<void>}
178178
*/
179179
static async started(fn = null) {

test/unit/els_test.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ describe('els', function () {
3838
let elementUsed
3939

4040
await els.element('my test', '.selector', async el => {
41-
elementUsed = el
41+
elementUsed = await el
4242
})
4343

44-
await recorder.promise()
45-
4644
assert.equal(elementUsed, 'el1')
4745
})
4846

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

5351
await els.element('.selector', async el => {
54-
elementUsed = el
52+
elementUsed = await el
5553
})
5654

5755
assert.equal(elementUsed, 'el1')
@@ -77,7 +75,6 @@ describe('els', function () {
7775
},
7876
new StepConfig().timeout(0.01),
7977
)
80-
await recorder.promise()
8178
throw new Error('should have thrown error')
8279
} catch (e) {
8380
recorder.catch()
@@ -147,7 +144,6 @@ describe('els', function () {
147144
await els.eachElement('.selector', async el => {
148145
throw new Error(`failed on ${el}`)
149146
})
150-
await recorder.promise()
151147
throw new Error('should have thrown error')
152148
} catch (e) {
153149
expect(e.message).to.equal('failed on el1')
@@ -167,7 +163,6 @@ describe('els', function () {
167163

168164
try {
169165
await els.expectElement('.selector', async () => false)
170-
await recorder.promise()
171166
throw new Error('should have thrown error')
172167
} catch (e) {
173168
expect(e.cliMessage()).to.include('element (.selector)')
@@ -187,7 +182,6 @@ describe('els', function () {
187182

188183
try {
189184
await els.expectAnyElement('.selector', async () => false)
190-
await recorder.promise()
191185
throw new Error('should have thrown error')
192186
} catch (e) {
193187
expect(e.cliMessage()).to.include('any element of (.selector)')
@@ -207,7 +201,6 @@ describe('els', function () {
207201

208202
try {
209203
await els.expectAllElements('.selector', async el => el !== 'el2')
210-
await recorder.promise()
211204
throw new Error('should have thrown error')
212205
} catch (e) {
213206
expect(e.cliMessage()).to.include('element #2 of (.selector)')

0 commit comments

Comments
 (0)