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
Juan Picado 73d34bf9c4
build: upgrade to jest 27 (#2297)
* migrate to jest 27

* test
2021-06-13 09:14:04 +02:00

37 lines
942 B
TypeScript

import os from 'os';
import path from 'path';
import buildDebug from 'debug';
import NodeEnvironment from 'jest-environment-node';
const fs = require('fs');
const __global = require('../utils/global');
const debug = buildDebug('verdaccio:e2e:env');
class E2ECliTestEnvironment extends NodeEnvironment {
constructor(config) {
super(config);
}
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
this.global.__namespace = __global;
debug(`current directory: ${process.cwd()}`);
}
async teardown() {
// TODO: clean folder
}
public runScript(script): any {
return super.runScript(script);
}
}
export default E2ECliTestEnvironment;