Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

Easier support for browserstack #3173

Open AVGP opened 7 years ago

AVGP commented 7 years ago

I have just setup a polymer-cli project with browserstack and it works fine, but it required a few additional configuration files to be created.

I saw that Sauce Labs is supported out of the box, but unlike Browserstack it isn't free for open source projects (or at least I can't find it), so I was wondering if there would be interest for adding similar browserstack support? I am happy to do this, if it's something that is welcome here.. 🙆‍♂️

toshovski commented 7 years ago

I would be interessted too. @AVGP could you please share with us how you managed to setup browserstack.

hotforfeature commented 7 years ago

If it helps, this was my old process of getting Browserstack's WebDriver API to work natively with WCT.

package.json

{
  "name": "my-element",
  "scripts": {
    "test": "polymer test",
    "test:ci": "node browserstack.js"
  },
  "devDependencies": {
    "browserstack-local": "^1.3.0",
    "polymer-cli": "^1.3.0"
  }
}

browserstack.js

const browserstack = require('browserstack-local');
const { spawn } = require('child_process');

// Start Browserstack local tunnel
const local = new browserstack.Local();
local.start({
  key: 'ACCESS_KEY'
}, () => {
  // Then run "wct test --configFile browserstack.wct.conf.js"
  const child = spawn('wct', [
    'test',
    '--configFile',
    'browserstack.wct.conf.js'
  ], { stdio: 'inherit' });
  child.on('close', code => {
    local.stop(() => {
      process.exit(code);
    });
  });
});

browserstack.wct.conf.js

const package = require('./package.json');

module.exports = {
  // Directly set active browsers to use
  activeBrowsers: [{
    browserName: 'ie',
    version: '11'
  }, {
    browserName: 'edge'
  }, {
    browserName: 'chrome'
  }, {
    browserName: 'firefox'
  }, {
    browserName: 'safari',
    os: 'OS X',
    os_version: 'Sierra'
  }],
  browserOptions: {
    // Point all browsers to Browserstack's WD api
    url: 'https://hub-cloud.browserstack.com/wd/hub',
    // Name of the test, build, and project. I was using Amazon AWS CodeBuild, use your own CI env build variable
    name: 'WCT',
    build: process.env.CODEBUILD_BUILD_ID || new Date(),
    project: package.name,
    // Browserstack auth
    'browserstack.user': 'USER_NAME',
    'browserstack.key': 'ACCESS_KEY',
    // Use browserstack local tunnel that we started
    'browserstack.local': true
  },
  webserver: {
    pathMappings: [
      {
        '/components/my-element/bower_components': 'bower_components'
      }
    ]
  }
};
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.