mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
73d34bf9c4
* migrate to jest 27 * test
38 lines
942 B
TypeScript
38 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;
|