UNPKG

@danielkalen/simplybind

Version:

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

68 lines (56 loc) 2.48 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': if process.env.suiteName then new RegExp(process.env.suiteName) else /SimplyBind/ 'runTimes': process.env.run or 7 'runDelay': process.env.delay or 500 'dontClose': process.env.dontClose 'direction': 'asc' 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)-> settings.grep.test(label) .then (elements)-> elements = elements.reverse() if settings.direction is 'desc' Promise.all elements.map (element)-> element.findElement(WD.By.tagName('a')).then (aElement)-> aElement.getAttribute('href').then (href)-> href.replace(indexURL+'/', '') .then (hrefs)-> Promise.each hrefs, (href)-> D.get("#{indexURL}/#{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.get(indexURL) else D.close()