UNPKG

@danielkalen/simplybind

Version:

Magically simple, framework-less one-way/two-way data binding for frontend/backend in ~5kb.

66 lines (54 loc) 2.34 kB
Promise = require 'bluebird' WD = require 'selenium-webdriver' chrome = require 'selenium-webdriver/chrome' firefox = require 'selenium-webdriver/firefox' firefoxOptions = new firefox.Options() firefoxOptions.setBinary '/Applications/FirefoxDeveloperEdition.app' chromeRegOptions = new chrome.Options() chromeRegOptions.setChromeBinaryPath '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' chromeCanaryOptions = new chrome.Options() chromeCanaryOptions.setChromeBinaryPath '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary' indexURL = 'http://localhost:13947' settings = 'browser': process.env.browser or 'chrome' 'grep': process.env.suiteName or 'SimplyBind' 'runTimes': process.env.run or 7 'runDelay': process.env.delay or 500 'dontClose': process.env.dontClose D = new WD.Builder() .forBrowser(if settings.browser is 'canary' then 'chrome' else settings.browser) # .setFirefoxOptions(firefoxOptions) .setChromeOptions(if settings.browser is 'canary' then chromeCanaryOptions else chromeRegOptions) .build() D.manage().timeouts().setScriptTimeout(300000) D.get(indexURL) D.findElements(WD.By.className('testSuite_index-item')) .then (elements)-> WD.promise.filter elements, (element)-> element.findElement(WD.By.className('testSuite_index-item-title')).getText().then (label)-> label.includes(settings.grep) .then (elements)-> Promise.all elements.reverse().map (element)-> element.findElement(WD.By.tagName('a')).then (aElement)-> aElement.getAttribute('href').then (href)-> href .then (hrefs)-> Promise.each hrefs, (href)-> D.navigate().to(href) .then ()-> D.wait WD.until.elementLocated(WD.By.className 'testSuite-list-item') .then ()-> D.sleep(1000) .then ()-> D.executeAsyncScript ()-> done = arguments[arguments.length - 1] settings = arguments[0] PromiseB.each $('.testSuite-list-item').toArray(), (el)-> benchmark = $(el).data 'TestSuite' PromiseB.each (for i in [1..settings.runTimes] then ()-> benchmark.run().then ()-> new PromiseB (resolve)-> setTimeout resolve, settings.runDelay ), (run)-> run() .then(done) .catch (err)-> throw err done() , settings .then ()-> if settings.dontClose then D.navigate().to(indexURL) else D.close()