pull/4260/head
yann300 1 year ago committed by Aniket
parent 2c6f07b7ba
commit 7ea52cb35c
  1. 28
      apps/remix-ide-e2e/src/commands/waitForElementNotContainsText.ts
  2. 2
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  3. 1
      apps/remix-ide-e2e/src/types/index.d.ts

@ -0,0 +1,28 @@
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class WaitForElementNotContainsText extends EventEmitter {
command (this: NightwatchBrowser, id: string, value: string, timeout = 10000): NightwatchBrowser {
let waitId // eslint-disable-line
let currentValue
const runid = setInterval(() => {
this.api.getText(id, (result) => {
currentValue = result.value
if (typeof result.value === 'string' && result.value.indexOf(value) !== -1) {
clearInterval(runid)
clearTimeout(waitId)
this.api.assert.ok(false, `WaitForElementContainsText ${id} contains ${value} . It should not`)
this.emit('complete')
}
})
}, 200)
waitId = setTimeout(() => {
clearInterval(runid)
this.api.assert.fail(`TimeoutError: An error occurred while running .waitForElementContainsText() command on ${id} after ${timeout} milliseconds. expected: ${value} - got: ${currentValue}`)
}, timeout)
return this
}
}
module.exports = WaitForElementNotContainsText

@ -356,6 +356,8 @@ module.exports = {
})
.useCss()
.waitForElementContainsText('*[data-id="terminalJournal"]', 'test running free function', 120000)
.WaitForElementNotContainsText('*[data-id="terminalJournal"]', `test running free function
test running free function`)
}
}

@ -69,6 +69,7 @@ declare module 'nightwatch' {
switchWorkspace: (workspaceName: string) => NightwatchBrowser
switchEnvironment: (provider: string) => NightwatchBrowser
connectToExternalHttpProvider: (url: string, identifier: string) => NightwatchBrowser
WaitForElementNotContainsText: (id: string, value: string, timeout: number = 10000) => NightwatchBrowser
}
export interface NightwatchBrowser {

Loading…
Cancel
Save