forked from facebook/react
/
test.js
49 lines (40 loc) · 1.25 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
'use strict';
const {exec} = require('child-process-promise');
const {Finder} = require('firefox-profile');
const {resolve} = require('path');
const {argv} = require('yargs');
const EXTENSION_PATH = resolve('./firefox/build/unpacked');
const START_URL = argv.url || 'https://reactjs.org/';
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();