forked from sombochea/verdaccio-ui
build: e2e integration with puppeteer (#192)
* build: add e2e testing scripts * build: add e2e testing scripts * chore: fix script * chore: fix script * chore: ignore e2e normal test * chore: fix node_latest_browser * chore: move lint to prepare * chore: fix lint * chore: add local theme * fix: e2e tests
This commit is contained in:
committed by
GitHub
parent
0c4fb7da13
commit
d1b3e6e3b5
60
test/e2e/registry-launcher.ts
Normal file
60
test/e2e/registry-launcher.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import path from 'path';
|
||||
import { fork } from 'child_process';
|
||||
|
||||
import { HTTP_STATUS } from '@verdaccio/commons-api';
|
||||
|
||||
export const CREDENTIALS = {
|
||||
user: 'foo',
|
||||
password: 'test',
|
||||
};
|
||||
|
||||
export default class VerdaccioProcess {
|
||||
private bridge;
|
||||
private config;
|
||||
private childFork;
|
||||
|
||||
public constructor(config, bridge) {
|
||||
this.config = config;
|
||||
this.bridge = bridge;
|
||||
}
|
||||
|
||||
public init(verdaccioPath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._start(verdaccioPath, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
private _start(verdaccioPath: string, resolve: Function, reject: Function) {
|
||||
const verdaccioRegisterWrap: string = path.join(__dirname, verdaccioPath);
|
||||
const childOptions = {
|
||||
silent: false,
|
||||
};
|
||||
|
||||
const { configPath, port } = this.config;
|
||||
this.childFork = fork(verdaccioRegisterWrap, ['-c', configPath, '-l', port as string], childOptions);
|
||||
|
||||
this.childFork.on('message', msg => {
|
||||
// verdaccio_started is a message that comes from verdaccio in debug mode that notify has been started
|
||||
if ('verdaccio_started' in msg) {
|
||||
this.bridge
|
||||
.debug()
|
||||
.status(HTTP_STATUS.OK)
|
||||
.then(body => {
|
||||
this.bridge
|
||||
.auth(CREDENTIALS.user, CREDENTIALS.password)
|
||||
.status(HTTP_STATUS.CREATED)
|
||||
.body_ok(new RegExp(CREDENTIALS.user))
|
||||
.then(() => resolve([this, body.pid]), reject);
|
||||
}, reject);
|
||||
}
|
||||
});
|
||||
|
||||
this.childFork.on('error', err => reject([err, this]));
|
||||
this.childFork.on('disconnect', err => reject([err, this]));
|
||||
this.childFork.on('exit', err => reject([err, this]));
|
||||
}
|
||||
|
||||
public stop(): void {
|
||||
return this.childFork.kill('SIGINT');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user