shells/browser/firefox/test.js (16 lines of code) (raw):

#!/usr/bin/env node /** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ const { exec } = require('child-process-promise'); const { Finder } = require('firefox-profile'); const { resolve } = require('path'); const EXTENSION_PATH = resolve('shells/browser/firefox/build/unpacked'); const START_URL = 'https://facebook.github.io/react/'; const main = async () => { const finder = new Finder(); // Use default Firefox profile for testing purposes. // This prevents users from having to re-login-to sites before testing. const findPathPromise = new Promise((resolvePromise, rejectPromise) => { finder.getPath('default', (error, profile) => { if (error) { rejectPromise(error); } else { resolvePromise(profile); } }); }); const options = [ `--source-dir=${EXTENSION_PATH}`, `--start-url=${START_URL}`, '--browser-console', ]; try { const path = await findPathPromise; const trimmedPath = path.replace(' ', '\\ '); options.push(`--firefox-profile=${trimmedPath}`); } catch (err) { console.warn('Could not find default profile, using temporary profile.'); } try { await exec(`web-ext run ${options.join(' ')}`); } catch (err) { console.error('`web-ext run` failed', err.stdout, err.stderr); } }; main();