1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

BackstopJSでProxyを通したり、ベーシック認証を通したり。

Posted at

BackstopJSをProxyやベーシック認証のある環境で利用する場合の各種設定方法です。
※ Chrome-Headless のエンジンは「puppeteer」を使用した場合になります。

Proxyの設定

  "engineOptions": {
    "args": ["--no-sandbox"]
  },

  "engineOptions": {
    "args": ["--no-sandbox", "--proxy-server=http://proxy.example.com:8080"]
  },

ベーシック認証の設定

../backstop_data/engine_scripts/puppet/onBefore.js
module.exports = async (page, scenario, vp) => {
  await require('./loadCookies')(page, scenario);
};

../backstop_data/engine_scripts/puppet/onBefore.js
module.exports = async (page, scenario, vp) => {
  const USERNAME = 'username';
  const PASSWORD = 'password';

  await page.setExtraHTTPHeaders({
    Authorization: `Basic ${new Buffer(`${USERNAME}:${PASSWORD}`).toString('base64')}`
  });

  await require('./loadCookies')(page, scenario);
};
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?