0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/e2e-cli/setup/test_environment.ts

38 lines
942 B
TypeScript
Raw Normal View History

2019-12-15 02:52:55 -05:00
import os from 'os';
import path from 'path';
import buildDebug from 'debug';
2019-12-15 02:52:55 -05:00
import NodeEnvironment from 'jest-environment-node';
2020-08-13 16:36:23 -05:00
const fs = require('fs');
2019-12-15 02:52:55 -05:00
const __global = require('../utils/global');
const debug = buildDebug('verdaccio:e2e:env');
2019-12-15 11:18:40 -05:00
class E2ECliTestEnvironment extends NodeEnvironment {
2019-12-15 02:52:55 -05:00
constructor(config) {
super(config);
2019-12-15 02:52:55 -05:00
}
public 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 02:52:55 -05:00
this.global.__namespace = __global;
debug(`current directory: ${process.cwd()}`);
2019-12-15 02:52:55 -05:00
}
async teardown() {
// TODO: clean folder
}
2019-12-15 02:52:55 -05:00
public runScript(script): any {
2019-12-15 02:52:55 -05:00
return super.runScript(script);
}
}
2019-12-15 11:18:40 -05:00
export default E2ECliTestEnvironment;