<commit_before>'use strict';

var webdriverio = require('webdriverio');

var e = require('./setup/test-environment');
var C = require('./setup/test-constants');

// Global before and after

before(function(done) {
    this.timeout(30000);

    if (C.CONFIG.login.enabled) {
        throw new Error('Login security is enabled! Please disable login security in cfg/nodecg.json before running tests');
    }

    if (C.CONFIG.ssl.enabled) {
        throw new Error('SSL is enabled! Please disable SSL in cfg/nodecg.json before running tests');
    }

    e.server.once('started', function() {
        /** Extension API setup **/
        e.apis.extension = e.server.getExtensions()[C.BUNDLE_NAME];

        e.browser.client = webdriverio.remote({
            desiredCapabilities: {
                name: "Travis job " + process.env.TRAVIS_JOB_NUMBER,
                build: process.env.TRAVIS_BUILD_NUMBER,
                tags: [process.env.TRAVIS_BRANCH, process.env.TRAVIS_COMMIT, process.env.TRAVIS_COMMIT_RANGE, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_TAG],
                browserName: 'chrome',
                version: 'beta',
                tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
            },
            host: 'ondemand.saucelabs.com',
            port: 80,
            user: process.env.SAUCE_USERNAME,
            key: process.env.SAUCE_ACCESS_KEY
        })
            .init()
            .timeoutsAsyncScript(10000)
            .newWindow(C.DASHBOARD_URL, 'NodeCG dashboard', '')
            .getCurrentTabId(function(err, tabId) {
                if (err) {
                    throw err;
                }

                e.browser.tabs.dashboard = tabId;
            })
            .executeAsync(function(done) {
                var checkForApi;
                checkForApi = setInterval(function(done) {
                    if (typeof window.dashboardApi !== 'undefined') {
                        clearInterval(checkForApi);
                        done();
                    }
                }.bind(this, done), 50);
            }, function(err) {
                if (err) {
                    throw err;
                }
            })
            .newWindow(C.VIEW_URL, 'NodeCG test bundle view', '')
            .getCurrentTabId(function(err, tabId) {
                if (err) {
                    throw err;
                }

                e.browser.tabs.view = tabId;
            })
            .executeAsync(function(done) {
                var checkForApi;
                checkForApi = setInterval(function(done) {
                    if (typeof window.viewApi !== 'undefined') {
                        clearInterval(checkForApi);
                        done();
                    }
                }.bind(this, done), 50);
            }, function(err) {
                if (err) {
                    throw err;
                }
            })
            .timeoutsAsyncScript(5000)
            .call(done);
    });
    e.server.start();
});
<commit_msg>Use setInterval to pass in arguments.<commit_after>'use strict';

var webdriverio = require('webdriverio');

var e = require('./setup/test-environment');
var C = require('./setup/test-constants');

// Global before and after

before(function(done) {
    this.timeout(30000);

    if (C.CONFIG.login.enabled) {
        throw new Error('Login security is enabled! Please disable login security in cfg/nodecg.json before running tests');
    }

    if (C.CONFIG.ssl.enabled) {
        throw new Error('SSL is enabled! Please disable SSL in cfg/nodecg.json before running tests');
    }

    e.server.once('started', function() {
        /** Extension API setup **/
        e.apis.extension = e.server.getExtensions()[C.BUNDLE_NAME];

        e.browser.client = webdriverio.remote({
            desiredCapabilities: {
                name: "Travis job " + process.env.TRAVIS_JOB_NUMBER,
                build: process.env.TRAVIS_BUILD_NUMBER,
                tags: [process.env.TRAVIS_BRANCH, process.env.TRAVIS_COMMIT, process.env.TRAVIS_COMMIT_RANGE, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_TAG],
                browserName: 'chrome',
                version: 'beta',
                tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
            },
            host: 'ondemand.saucelabs.com',
            port: 80,
            user: process.env.SAUCE_USERNAME,
            key: process.env.SAUCE_ACCESS_KEY
        })
            .init()
            .timeoutsAsyncScript(10000)
            .newWindow(C.DASHBOARD_URL, 'NodeCG dashboard', '')
            .getCurrentTabId(function(err, tabId) {
                if (err) {
                    throw err;
                }

                e.browser.tabs.dashboard = tabId;
            })
            .executeAsync(function(done) {
                var checkForApi;
                checkForApi = setInterval(function(done) {
                    if (typeof window.dashboardApi !== 'undefined') {
                        clearInterval(checkForApi);
                        done();
                    }
                }, 50, done);
            }, function(err) {
                if (err) {
                    throw err;
                }
            })
            .newWindow(C.VIEW_URL, 'NodeCG test bundle view', '')
            .getCurrentTabId(function(err, tabId) {
                if (err) {
                    throw err;
                }

                e.browser.tabs.view = tabId;
            })
            .executeAsync(function(done) {
                var checkForApi;
                checkForApi = setInterval(function(done) {
                    if (typeof window.viewApi !== 'undefined') {
                        clearInterval(checkForApi);
                        done();
                    }
                }, 50, done);
            }, function(err) {
                if (err) {
                    throw err;
                }
            })
            .timeoutsAsyncScript(5000)
            .call(done);
    });
    e.server.start();
});

{'fraction_non_alphanumeric': 0.11149768058316765, 'fraction_numerical': 0.0066269052352551355, 'mean_word_length': 1.4138344662135145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1492021', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1600, 'n_words': 307}