mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
558d78f32a
* feat: flexible template generator and manifest * chore: add changeset * chore: restore dep * chore: add docs * chore: update snapshots * chore: update docker examples for v5 * chore: refactor web module * chore: format * chore: refactor web api endpoints * test: add test for user login web * chore: refactor endpoints * chore: fix merge * chore: fix merge * Update ci.yml * chore: test * chore: add static * chore: update script * chore: fix e2e * chore: fix method * docs: update v5 relative docker example * chore: update html render * chore: update style * Update .prettierignore * chore: update changeset * chore: use pnpm6 on run test temporary ci * chore: drop node 16 for pnpm 6 * chore: update ci * chore: update ci * chore: update ci * chore: update ci * chore: remove circle ci * chore: better url prefix handling * chore: format code * chore: remove test node 10 * docs: add docker v5 relative revers proxy example * chore: use base html tag * chore: update test
79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
const fs = require('fs');
|
|
const os = require('os');
|
|
const path = require('path');
|
|
const debug = require('debug')('verdaccio:e2e:ui:puppeteer');
|
|
|
|
const NodeEnvironment = require('jest-environment-node');
|
|
const { yellow } = require('kleur');
|
|
const puppeteer = require('puppeteer');
|
|
|
|
const VerdaccioProcess = require('./registry-launcher');
|
|
const Server = require('./server');
|
|
|
|
const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
|
|
|
|
class VerdaccioConfig {
|
|
constructor(storagePath, configPath, domainPath, port) {
|
|
this.storagePath = storagePath;
|
|
this.configPath = configPath;
|
|
this.domainPath = domainPath;
|
|
this.port = port;
|
|
}
|
|
}
|
|
|
|
class PuppeteerEnvironment extends NodeEnvironment {
|
|
constructor(config) {
|
|
super(config);
|
|
}
|
|
|
|
async setup() {
|
|
const config1 = new VerdaccioConfig(
|
|
path.join(__dirname, './store-e2e'),
|
|
path.join(__dirname, './config/config-scoped-e2e.yaml'),
|
|
'http://0.0.0.0:55558/',
|
|
55558
|
|
);
|
|
const config2 = new VerdaccioConfig(
|
|
path.join(__dirname, './store-e2e'),
|
|
path.join(__dirname, './config/config-protected-e2e.yaml'),
|
|
'http://0.0.0.0:55552/',
|
|
55552
|
|
);
|
|
const server1 = new Server.default(config1.domainPath);
|
|
const server2 = new Server.default(config2.domainPath);
|
|
const process1 = new VerdaccioProcess.default(config1, server1);
|
|
const process2 = new VerdaccioProcess.default(config2, server2);
|
|
const verdaccioPath = path.normalize(
|
|
path.join(process.cwd(), '../../packages/verdaccio/debug/bootstrap.js')
|
|
);
|
|
const fork = await process1.init(verdaccioPath);
|
|
const fork2 = await process2.init(verdaccioPath);
|
|
this.global.__VERDACCIO_E2E__ = fork[0];
|
|
this.global.__VERDACCIO__PROTECTED_E2E__ = fork2[0];
|
|
|
|
debug(yellow('Setup Test Environment.'));
|
|
await super.setup();
|
|
const wsEndpoint = fs.readFileSync(path.join(DIR, 'wsEndpoint'), 'utf8');
|
|
if (!wsEndpoint) {
|
|
throw new Error('wsEndpoint not found');
|
|
}
|
|
this.global.__SERVER__ = server1;
|
|
this.global.__SERVER_PROTECTED__ = server2;
|
|
this.global.__BROWSER__ = await puppeteer.connect({
|
|
browserWSEndpoint: wsEndpoint,
|
|
});
|
|
}
|
|
|
|
async teardown() {
|
|
debug(yellow('Teardown Test Environment.'));
|
|
await super.teardown();
|
|
this.global.__VERDACCIO_E2E__.stop();
|
|
this.global.__VERDACCIO__PROTECTED_E2E__.stop();
|
|
}
|
|
|
|
runScript(script) {
|
|
return super.runScript(script);
|
|
}
|
|
}
|
|
|
|
module.exports = PuppeteerEnvironment;
|