0

如何在 BrowserStack 上使用 web-component-tester 测试 Polymer 元素?

我找到了这个演示,但会话超时。

4

1 回答 1

0

我终于设法通过使用以下配置解决了这个问题wct.conf.js

var path = require('path');

var ret = {
  'webserver': {
    'pathMappings': []
  }
};

var mapping = {};
var rootPath = (__dirname).split(path.sep).slice(-1)[0];

mapping['/components/' + rootPath  +
'/app/bower_components'] = 'bower_components';

ret.webserver.pathMappings.push(mapping);

/**
 * Adds BrowserStack config
 */
function configBrowserStack(config) {
  var user = process.env.BROWSERSTACK_USER;
  var key = process.env.BROWSERSTACK_ACCESSKEY;
  if (!user || !key) {
    throw new Error('Missing BrowserStack credentials. Did you forget to set BROWSERSTACK_USER and/or BROWSERSTACK_KEY?');
  }

  var url = process.env.BROWSERSTACK_URL
    || 'https://' + user + ':' + key + '@hub.browserstack.com/wd/hub';

  var ALL_BROWSERS = require(__dirname + '/default-browserstack-browsers.json');
  var browsers = ALL_BROWSERS.map(function(b) {
    b['browserstack.local'] = process.env.BROWSERSTACK_LOCAL;
    b['browserstack.localidentifier'] = process.env.BROWSERSTACK_LOCAL_IDENTIFIER;
    b['browserstack.build'] = process.env.BROWSERSTACK_BUILD;
    b['url'] = url;
    return b;
  });

  config.activeBrowsers = config.activeBrowsers || [];
  config.activeBrowsers = config.activeBrowsers.concat(browsers);
}

configBrowserStack(ret);

module.exports = ret;
于 2017-03-21T07:48:24.917 回答