Skip to content

Commit 6c02fc6

Browse files
authored
Merge pull request #112 from bufferoverflow/test/align-with-verdaccio
test: align functional test suite to verdaccio
2 parents b5290b9 + fd2b97b commit 6c02fc6

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"@verdaccio/eslint-config": "^8.5.0",
7171
"@verdaccio/types": "^8.5.0",
7272
"body-parser": "^1.19.0",
73-
"chalk": "^2.4.2",
7473
"cross-env": "^6.0.3",
7574
"eslint": "^6.8.0",
7675
"express": "^4.17.1",
@@ -80,6 +79,7 @@
8079
"in-publish": "^2.0.0",
8180
"jest": "^24.9.0",
8281
"jest-environment-node": "^24.9.0",
82+
"kleur": "3.0.3",
8383
"license-checker": "^25.0.1",
8484
"lodash": "^4.17.15",
8585
"markdownlint-cli": "^0.20.0",

test/functional/lib/environment.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path';
22

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

66
import { VerdaccioConfig } from '../../lib/verdaccio-server';
@@ -28,17 +28,17 @@ class FunctionalEnvironment extends NodeEnvironment {
2828
const SILENCE_LOG = !process.env.VERDACCIO_DEBUG;
2929
// @ts-ignore
3030
const DEBUG_INJECT: boolean = process.env.VERDACCIO_DEBUG_INJECT ? process.env.VERDACCIO_DEBUG_INJECT : false;
31-
const forkList = [];
32-
const serverList = [];
31+
const forkList: any[] = [];
32+
const serverList: IServerBridge[] = [];
3333
const pathStore = path.join(__dirname, '../store');
3434
const listServers = [
3535
{
3636
port: PORT_SERVER_1,
3737
config: '/config-1.yaml',
3838
storage: '/test-storage1',
39-
},
39+
}
4040
];
41-
console.log(chalk.green('Setup Verdaccio Servers'));
41+
console.log(green('Setup Verdaccio Servers'));
4242

4343
const app = await this.startWeb();
4444
this.global.__GITLAB_SERVER__ = app;
@@ -47,16 +47,14 @@ class FunctionalEnvironment extends NodeEnvironment {
4747
const verdaccioConfig = new VerdaccioConfig(
4848
path.join(pathStore, config.storage),
4949
path.join(pathStore, config.config),
50-
`http://${DOMAIN_SERVERS}:${config.port}/`,
51-
config.port
52-
);
53-
console.log(chalk.magentaBright(`Running registry ${config.config} on port ${config.port}`));
50+
`http://${DOMAIN_SERVERS}:${config.port}/`, config.port);
51+
console.log(magenta(`Running registry ${config.config} on port ${config.port}`));
5452
const server: IServerBridge = new Server(verdaccioConfig.domainPath);
5553
serverList.push(server);
5654
const process = new VerdaccioProcess(verdaccioConfig, server, SILENCE_LOG, DEBUG_INJECT);
5755

5856
const fork = await process.init();
59-
console.log(chalk.blue(`Fork PID ${fork[1]}`));
57+
console.log(blue(`Fork PID ${fork[1]}`));
6058
forkList.push(fork);
6159
}
6260

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

6765
public async teardown() {
6866
await super.teardown();
69-
console.log(chalk.yellow('Teardown Test Environment.'));
67+
console.log(yellow('Teardown Test Environment.'));
68+
69+
if (!this.global.__SERVERS_PROCESS__) {
70+
throw new Error("There are no servers to stop");
71+
}
72+
7073
// shutdown verdaccio
7174
for (const server of this.global.__SERVERS_PROCESS__) {
7275
server[0].stop();

test/functional/lib/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module.exports = async () => {
2-
// here we should create dinamically config files
1+
module.exports = async function() {
2+
// here we should create dynamically config files
33
};

test/functional/pre-setup.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require('@babel/register')({
2-
extensions: ['.ts', '.js'],
2+
extensions: ['.ts', '.js']
33
});
4-
const chalk = require('chalk');
54

6-
module.exports = async () => {
7-
console.log(chalk.blue('setup: starting servers'));
5+
import { blue } from 'kleur';
86

7+
module.exports = async () => {
8+
console.log(blue('setup: starting servers'));
99
require('./lib/setup');
10-
};
10+
}

test/functional/teardown.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const chalk = require('chalk');
1+
import { blue } from 'kleur';
22

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

0 commit comments

Comments
 (0)