1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/e2e/setup.js

29 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-02-08 22:24:34 +01:00
const chalk = require('chalk');
const puppeteer = require('puppeteer');
const fs = require('fs');
const mkdirp = require('mkdirp');
const os = require('os');
const path = require('path');
2018-02-09 08:42:34 +01:00
const {VerdaccioConfig} = require("../src/verdaccio-server");
const VerdaccioProcess = require("../src/server_process");
const Server = require("../src/server");
2018-02-08 22:24:34 +01:00
const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
module.exports = async function() {
2018-02-09 08:42:34 +01:00
const config1 = new VerdaccioConfig(
path.join(__dirname, './store-e2e'),
path.join(__dirname, './config-e2e.yaml'),
'http://localhost:55558/', 55558);
const server1 = new Server.default(config1.domainPath);
const process1 = new VerdaccioProcess.default(config1, server1, false);
const fork = await process1.init();
2018-02-08 22:24:34 +01:00
console.log(chalk.green('Setup Puppeteer'));
const browser = await puppeteer.launch({});
global.__BROWSER__ = browser;
2018-02-09 08:42:34 +01:00
global.__VERDACCIO_E2E__ = fork[0];
2018-02-08 22:24:34 +01:00
mkdirp.sync(DIR);
fs.writeFileSync(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint());
};