Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unstable els tests #4805

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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