2019-12-15 08:52:55 +01:00
|
|
|
import os from 'os';
|
|
|
|
import path from 'path';
|
2020-12-21 10:22:06 +01:00
|
|
|
import buildDebug from 'debug';
|
2019-12-15 08:52:55 +01:00
|
|
|
import NodeEnvironment from 'jest-environment-node';
|
2020-08-13 23:36:23 +02:00
|
|
|
const fs = require('fs');
|
2020-12-21 10:22:06 +01:00
|
|
|
|
2019-12-15 08:52:55 +01:00
|
|
|
const __global = require('../utils/global');
|
|
|
|
|
2020-12-21 10:22:06 +01:00
|
|
|
const debug = buildDebug('verdaccio:e2e:env');
|
|
|
|
|
2019-12-15 17:18:40 +01:00
|
|
|
class E2ECliTestEnvironment extends NodeEnvironment {
|
2019-12-15 08:52:55 +01:00
|
|
|
constructor(config) {
|
2021-03-14 08:42:46 +01:00
|
|
|
super(config);
|
2019-12-15 08:52:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async setup() {
|
2020-12-21 10:22:06 +01:00
|
|
|
// create an unique suite location peer test to avoid conflicts
|
2021-03-14 08:42:46 +01:00
|
|
|
const tempRoot = fs.mkdtempSync(
|
|
|
|
path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-suite-test-')
|
|
|
|
);
|
2020-12-21 10:22:06 +01:00
|
|
|
debug('suite temporary folder %o', tempRoot);
|
|
|
|
__global.addItem('dir-suite-root', tempRoot);
|
|
|
|
// @ts-ignore
|
2019-12-15 08:52:55 +01:00
|
|
|
this.global.__namespace = __global;
|
2020-12-21 10:22:06 +01:00
|
|
|
debug(`current directory: ${process.cwd()}`);
|
2019-12-15 08:52:55 +01:00
|
|
|
}
|
|
|
|
|
2020-12-21 10:22:06 +01:00
|
|
|
async teardown() {
|
|
|
|
// TODO: clean folder
|
|
|
|
}
|
2019-12-15 08:52:55 +01:00
|
|
|
|
2020-04-09 11:09:30 +02:00
|
|
|
runScript(script): any {
|
2019-12-15 08:52:55 +01:00
|
|
|
return super.runScript(script);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-15 17:18:40 +01:00
|
|
|
export default E2ECliTestEnvironment;
|