1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/e2e-cli/setup/test_environment.ts

38 lines
928 B
TypeScript
Raw Normal View History

2019-12-15 08:52:55 +01:00
import os from 'os';
import path from 'path';
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');
2019-12-15 08:52:55 +01:00
const __global = require('../utils/global');
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) {
super(config);
2019-12-15 08:52:55 +01:00
}
async setup() {
// create an unique suite location peer test to avoid conflicts
const tempRoot = fs.mkdtempSync(
path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-suite-test-')
);
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;
debug(`current directory: ${process.cwd()}`);
2019-12-15 08:52:55 +01:00
}
async teardown() {
// TODO: clean folder
}
2019-12-15 08:52:55 +01: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;