Skip to content

Commit

Permalink
test: align functional test suite to verdaccio
Browse files Browse the repository at this point in the history
  • Loading branch information
bufferoverflow committed Jan 7, 2020
1 parent b5290b9 commit fd2b97b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"@verdaccio/eslint-config": "^8.5.0",
"@verdaccio/types": "^8.5.0",
"body-parser": "^1.19.0",
"chalk": "^2.4.2",
"cross-env": "^6.0.3",
"eslint": "^6.8.0",
"express": "^4.17.1",
Expand All @@ -80,6 +79,7 @@
"in-publish": "^2.0.0",
"jest": "^24.9.0",
"jest-environment-node": "^24.9.0",
"kleur": "3.0.3",
"license-checker": "^25.0.1",
"lodash": "^4.17.15",
"markdownlint-cli": "^0.20.0",
Expand Down
25 changes: 14 additions & 11 deletions test/functional/lib/environment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';

import chalk from 'chalk';
import { yellow, green, blue, magenta } from 'kleur';
import NodeEnvironment from 'jest-environment-node';

import { VerdaccioConfig } from '../../lib/verdaccio-server';
Expand Down Expand Up @@ -28,17 +28,17 @@ class FunctionalEnvironment extends NodeEnvironment {
const SILENCE_LOG = !process.env.VERDACCIO_DEBUG;
// @ts-ignore
const DEBUG_INJECT: boolean = process.env.VERDACCIO_DEBUG_INJECT ? process.env.VERDACCIO_DEBUG_INJECT : false;
const forkList = [];
const serverList = [];
const forkList: any[] = [];
const serverList: IServerBridge[] = [];
const pathStore = path.join(__dirname, '../store');
const listServers = [
{
port: PORT_SERVER_1,
config: '/config-1.yaml',
storage: '/test-storage1',
},
}
];
console.log(chalk.green('Setup Verdaccio Servers'));
console.log(green('Setup Verdaccio Servers'));

const app = await this.startWeb();
this.global.__GITLAB_SERVER__ = app;
Expand All @@ -47,16 +47,14 @@ class FunctionalEnvironment extends NodeEnvironment {
const verdaccioConfig = new VerdaccioConfig(
path.join(pathStore, config.storage),
path.join(pathStore, config.config),
`http://${DOMAIN_SERVERS}:${config.port}/`,
config.port
);
console.log(chalk.magentaBright(`Running registry ${config.config} on port ${config.port}`));
`http://${DOMAIN_SERVERS}:${config.port}/`, config.port);
console.log(magenta(`Running registry ${config.config} on port ${config.port}`));
const server: IServerBridge = new Server(verdaccioConfig.domainPath);
serverList.push(server);
const process = new VerdaccioProcess(verdaccioConfig, server, SILENCE_LOG, DEBUG_INJECT);

const fork = await process.init();
console.log(chalk.blue(`Fork PID ${fork[1]}`));
console.log(blue(`Fork PID ${fork[1]}`));
forkList.push(fork);
}

Expand All @@ -66,7 +64,12 @@ class FunctionalEnvironment extends NodeEnvironment {

public async teardown() {
await super.teardown();
console.log(chalk.yellow('Teardown Test Environment.'));
console.log(yellow('Teardown Test Environment.'));

if (!this.global.__SERVERS_PROCESS__) {
throw new Error("There are no servers to stop");
}

// shutdown verdaccio
for (const server of this.global.__SERVERS_PROCESS__) {
server[0].stop();
Expand Down
4 changes: 2 additions & 2 deletions test/functional/lib/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = async () => {
// here we should create dinamically config files
module.exports = async function() {
// here we should create dynamically config files
};
10 changes: 5 additions & 5 deletions test/functional/pre-setup.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require('@babel/register')({
extensions: ['.ts', '.js'],
extensions: ['.ts', '.js']
});
const chalk = require('chalk');

module.exports = async () => {
console.log(chalk.blue('setup: starting servers'));
import { blue } from 'kleur';

module.exports = async () => {
console.log(blue('setup: starting servers'));
require('./lib/setup');
};
}
4 changes: 2 additions & 2 deletions test/functional/teardown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const chalk = require('chalk');
import { blue } from 'kleur';

module.exports = async () => {
console.log(chalk.blue('teardown: all servers closed'));
console.log(blue('teardown: all servers closed'));
};

0 comments on commit fd2b97b

Please sign in to comment.