chore: reorganize setup files
This commit is contained in:
parent
10ccc4a59f
commit
3bf2196388
|
@ -117,7 +117,7 @@ jobs:
|
||||||
- restore_repo
|
- restore_repo
|
||||||
- run:
|
- run:
|
||||||
name: Test End-to-End ClI
|
name: Test End-to-End ClI
|
||||||
command: yarn run test:e2e:pkg
|
command: yarn run test:e2e:cli
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
"@verdaccio"
|
"@verdaccio"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-var-requires": ["warn"],
|
"@typescript-eslint/no-var-requires": 0,
|
||||||
"@typescript-eslint/ban-ts-ignore": 0,
|
"@typescript-eslint/ban-ts-ignore": 0,
|
||||||
"@typescript-eslint/no-inferrable-types": ["warn"],
|
"@typescript-eslint/no-inferrable-types": 0,
|
||||||
"@typescript-eslint/no-empty-function": ["warn"],
|
"@typescript-eslint/no-empty-function": 0,
|
||||||
"@typescript-eslint/no-this-alias": ["warn"],
|
"@typescript-eslint/no-this-alias": ["warn"],
|
||||||
"@typescript-eslint/no-use-before-define": 0,
|
"@typescript-eslint/no-use-before-define": 0,
|
||||||
"@typescript-eslint/array-type": ["warn"],
|
"@typescript-eslint/array-type": ["warn"],
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
"test:clean": "npx jest --clearCache",
|
"test:clean": "npx jest --clearCache",
|
||||||
"test:unit": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC FORCE_COLOR=1 jest --config ./jest.config.js --maxWorkers 2 --passWithNoTests",
|
"test:unit": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC FORCE_COLOR=1 jest --config ./jest.config.js --maxWorkers 2 --passWithNoTests",
|
||||||
"test:functional": "cross-env NODE_ENV=test jest --config ./test/jest.config.functional.js --testPathPattern ./test/functional/index* --passWithNoTests",
|
"test:functional": "cross-env NODE_ENV=test jest --config ./test/jest.config.functional.js --testPathPattern ./test/functional/index* --passWithNoTests",
|
||||||
"test:e2e:pkg": "cross-env NODE_ENV=test jest --config ./test/e2e-pkg/jest.config.e2e.pkg.js --passWithNoTests",
|
"test:e2e:cli": "cross-env NODE_ENV=test jest --config ./test/e2e-cli/jest.config.e2e.cli.js --passWithNoTests",
|
||||||
"test:e2e": "cross-env BABEL_ENV=test jest --config ./test/jest.config.e2e.js",
|
"test:e2e": "cross-env BABEL_ENV=test jest --config ./test/jest.config.e2e.js",
|
||||||
"test:all": "npm run test && npm run test:functional && npm run test:e2e & npm run test:e2e:pkg",
|
"test:all": "npm run test && npm run test:functional && npm run test:e2e & npm run test:e2e:pkg",
|
||||||
"pre:ci": "npm run lint",
|
"pre:ci": "npm run lint",
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"no-useless-escape": 0,
|
"no-useless-escape": 0,
|
||||||
"@typescript-eslint/explicit-function-return-type": 0
|
"@typescript-eslint/explicit-function-return-type": 0,
|
||||||
|
"@typescript-eslint/no-empty-function": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/no-var-requires": 0,
|
||||||
|
"@typescript-eslint/explicit-member-accessibility": 0
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
require('@babel/register')({
|
||||||
|
extensions: [".ts", ".js"]
|
||||||
|
});
|
||||||
|
module.exports = require('./setup/setup');
|
|
@ -0,0 +1,4 @@
|
||||||
|
require('@babel/register')({
|
||||||
|
extensions: [".ts", ".js"]
|
||||||
|
});
|
||||||
|
module.exports = require('./setup/teardown');
|
|
@ -1,10 +1,12 @@
|
||||||
const { defaults } = require('jest-config');
|
const { defaults } = require('jest-config');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'verdaccio-e2e-pkg-jest',
|
name: 'verdaccio-e2e-cli-jest',
|
||||||
verbose: true,
|
verbose: true,
|
||||||
collectCoverage: false,
|
collectCoverage: false,
|
||||||
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
|
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
|
||||||
testEnvironment: './env_babel.js',
|
testEnvironment: './env_babel.js',
|
||||||
|
globalSetup: './env_setup.js',
|
||||||
|
globalTeardown: './env_teardown.js',
|
||||||
testRegex: '(/test/e2e.*\\.spec)\\.ts'
|
testRegex: '(/test/e2e.*\\.spec)\\.ts'
|
||||||
};
|
};
|
|
@ -11,6 +11,7 @@
|
||||||
"sample"
|
"sample"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"jquery": "^3.4.1",
|
||||||
"lodash": "^4.17.15"
|
"lodash": "^4.17.15"
|
||||||
},
|
},
|
||||||
"author": "Juan Picado <juanpicado19@gmail.com>",
|
"author": "Juan Picado <juanpicado19@gmail.com>",
|
|
@ -0,0 +1,29 @@
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import os from "os";
|
||||||
|
import {yellow} from "kleur";
|
||||||
|
import {spawn} from "child_process";
|
||||||
|
import { npm } from '../utils/process';
|
||||||
|
import * as __global from '../utils/global.js';
|
||||||
|
|
||||||
|
module.exports = async () => {
|
||||||
|
const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-cli-e2e-'));
|
||||||
|
__global.addItem('dir-root', tempRoot);
|
||||||
|
console.log(yellow(`Add temp root folder: ${tempRoot}`));
|
||||||
|
fs.copyFileSync(
|
||||||
|
path.join(__dirname, '../config/_bootstrap_verdaccio.yaml'),
|
||||||
|
path.join(tempRoot, 'verdaccio.yaml'),
|
||||||
|
);
|
||||||
|
// @ts-ignore
|
||||||
|
global.__namespace = __global;
|
||||||
|
console.log(`current directory: ${process.cwd()}`);
|
||||||
|
// @ts-ignore
|
||||||
|
global.registryProcess = spawn(
|
||||||
|
'node',
|
||||||
|
[require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'],
|
||||||
|
{ cwd: tempRoot, stdio: 'inherit' },
|
||||||
|
);
|
||||||
|
|
||||||
|
// publish current build version on local registry
|
||||||
|
await npm('publish', '--registry' ,'http://localhost:4873');
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
module.exports = async function() {
|
||||||
|
// @ts-ignore
|
||||||
|
global.registryProcess.kill();
|
||||||
|
};
|
|
@ -0,0 +1,28 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
import os from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
import NodeEnvironment from 'jest-environment-node';
|
||||||
|
const __global = require('../utils/global');
|
||||||
|
// import { npm } from '../utils/process';
|
||||||
|
|
||||||
|
|
||||||
|
class PuppeteerEnvironment extends NodeEnvironment {
|
||||||
|
constructor(config) {
|
||||||
|
super(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
async setup() {
|
||||||
|
const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-suite-test-'));
|
||||||
|
__global.addItem('dir-root', tempRoot);
|
||||||
|
this.global.__namespace = __global;
|
||||||
|
console.log(`current directory: ${process.cwd()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async teardown() {}
|
||||||
|
|
||||||
|
runScript(script) {
|
||||||
|
return super.runScript(script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PuppeteerEnvironment;
|
|
@ -0,0 +1,29 @@
|
||||||
|
import path from 'path';
|
||||||
|
import { npm } from '../../utils/process';
|
||||||
|
|
||||||
|
function testExample() {
|
||||||
|
console.log('running example');
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function() {
|
||||||
|
await testExample();
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('npm install', ()=> {
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should install jquery', async () => {
|
||||||
|
console.log(`New directory: ${process.cwd()}`, __dirname);
|
||||||
|
process.chdir(path.join(__dirname, '../../projects/basic'));
|
||||||
|
console.log(`New directory: ${process.cwd()}`);
|
||||||
|
await npm('install', 'jquery', '--registry' ,'http://localhost:4873');
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
// console.log('--->', global.__namespace.getItem('dir-root'));
|
||||||
|
expect(true).toBe(true);
|
||||||
|
})
|
||||||
|
});
|
|
@ -12,6 +12,10 @@ export default async function() {
|
||||||
|
|
||||||
describe('test example', ()=> {
|
describe('test example', ()=> {
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
test('sub example', async () => {
|
test('sub example', async () => {
|
||||||
console.log(`New directory: ${process.cwd()}`, __dirname);
|
console.log(`New directory: ${process.cwd()}`, __dirname);
|
||||||
process.chdir(path.join(__dirname, '../../projects/basic'));
|
process.chdir(path.join(__dirname, '../../projects/basic'));
|
||||||
|
@ -19,7 +23,7 @@ describe('test example', ()=> {
|
||||||
await npm('install', '--registry' ,'http://localhost:4873');
|
await npm('install', '--registry' ,'http://localhost:4873');
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
console.log('--->', global.__namespace.getItem('dir-root'));
|
// console.log('--->', global.__namespace.getItem('dir-root'));
|
||||||
expect(true).toBe(true);
|
expect(true).toBe(true);
|
||||||
})
|
})
|
||||||
});
|
});
|
|
@ -1,49 +0,0 @@
|
||||||
import { yellow } from 'kleur';
|
|
||||||
const fs = require('fs');
|
|
||||||
import os from 'os';
|
|
||||||
import {ChildProcess, spawn} from 'child_process';
|
|
||||||
import path from 'path';
|
|
||||||
import NodeEnvironment from 'jest-environment-node';
|
|
||||||
const __global = require('../utils/global');
|
|
||||||
import { npm } from '../utils/process';
|
|
||||||
|
|
||||||
|
|
||||||
class PuppeteerEnvironment extends NodeEnvironment {
|
|
||||||
private registryProcess: ChildProcess | null;
|
|
||||||
constructor(config) {
|
|
||||||
super(config)
|
|
||||||
this.registryProcess = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async setup() {
|
|
||||||
const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-cli-e2e-'));
|
|
||||||
__global.addItem('dir-root', tempRoot);
|
|
||||||
console.log(yellow(`Add temp root folder: ${tempRoot}`));
|
|
||||||
fs.copyFileSync(
|
|
||||||
path.join(__dirname, '../config/_bootstrap_verdaccio.yaml'),
|
|
||||||
path.join(tempRoot, 'verdaccio.yaml'),
|
|
||||||
);
|
|
||||||
this.global.__namespace = __global;
|
|
||||||
console.log(`current directory: ${process.cwd()}`);
|
|
||||||
console.log('resolve-->', require.resolve('verdaccio/bin/verdaccio'));
|
|
||||||
this.registryProcess = spawn(
|
|
||||||
'node',
|
|
||||||
[require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'],
|
|
||||||
{ cwd: tempRoot, stdio: 'inherit' },
|
|
||||||
);
|
|
||||||
|
|
||||||
// publish current build version on local registry
|
|
||||||
await npm('publish', '--registry' ,'http://localhost:4873');
|
|
||||||
}
|
|
||||||
|
|
||||||
async teardown() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.registryProcess.kill()
|
|
||||||
}
|
|
||||||
|
|
||||||
runScript(script) {
|
|
||||||
return super.runScript(script);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default PuppeteerEnvironment;
|
|
Loading…
Reference in New Issue