0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-03-04 02:02:39 -05:00

test: add more packages managers to e2e cli (#3283)

* test: add more packages managers to e2e cli

* chore: remove old conf files

* Update ci.yml
This commit is contained in:
Juan Picado 2022-08-03 08:01:27 +02:00 committed by GitHub
parent 313c71c938
commit a4c17858bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 961 additions and 22 deletions

View file

@ -10,6 +10,7 @@ on:
- .changeset/**
- .github/workflows/ci.yml
- 'packages/**'
- 'test/**'
- 'docker-examples/**'
- 'jest/**'
- 'package.json'

214
pnpm-lock.yaml generated
View file

@ -1279,6 +1279,46 @@ importers:
'@verdaccio/test-cli-commons': link:../cli-commons
npm: 6.14.17
test/cli/e2e-npm7:
specifiers:
'@verdaccio/test-cli-commons': workspace:1.0.0
npm: latest-7
dependencies:
'@verdaccio/test-cli-commons': link:../cli-commons
npm: 7.24.2
test/cli/e2e-npm8:
specifiers:
'@verdaccio/test-cli-commons': workspace:1.0.0
npm: next-8
dependencies:
'@verdaccio/test-cli-commons': link:../cli-commons
npm: 8.15.1
test/cli/e2e-pnpm6:
specifiers:
'@verdaccio/test-cli-commons': workspace:1.0.0
pnpm: latest-6
dependencies:
'@verdaccio/test-cli-commons': link:../cli-commons
pnpm: 6.33.1
test/cli/e2e-pnpm7:
specifiers:
'@verdaccio/test-cli-commons': workspace:1.0.0
pnpm: next-7
dependencies:
'@verdaccio/test-cli-commons': link:../cli-commons
pnpm: 7.8.0
test/cli/e2e-yarn1:
specifiers:
'@verdaccio/test-cli-commons': workspace:1.0.0
yarn: 1.22.19
dependencies:
'@verdaccio/test-cli-commons': link:../cli-commons
yarn: 1.22.19
website:
specifiers:
'@docusaurus/core': 2.0.0-beta.20
@ -20667,6 +20707,161 @@ packages:
- worker-farm
- write-file-atomic
/npm/7.24.2:
resolution: {integrity: sha512-120p116CE8VMMZ+hk8IAb1inCPk4Dj3VZw29/n2g6UI77urJKVYb7FZUDW8hY+EBnfsjI/2yrobBgFyzo7YpVQ==}
engines: {node: '>=10'}
hasBin: true
dev: false
bundledDependencies:
- '@isaacs/string-locale-compare'
- '@npmcli/arborist'
- '@npmcli/ci-detect'
- '@npmcli/config'
- '@npmcli/map-workspaces'
- '@npmcli/package-json'
- '@npmcli/run-script'
- abbrev
- ansicolors
- ansistyles
- archy
- cacache
- chalk
- chownr
- cli-columns
- cli-table3
- columnify
- fastest-levenshtein
- glob
- graceful-fs
- hosted-git-info
- ini
- init-package-json
- is-cidr
- json-parse-even-better-errors
- libnpmaccess
- libnpmdiff
- libnpmexec
- libnpmfund
- libnpmhook
- libnpmorg
- libnpmpack
- libnpmpublish
- libnpmsearch
- libnpmteam
- libnpmversion
- make-fetch-happen
- minipass
- minipass-pipeline
- mkdirp
- mkdirp-infer-owner
- ms
- node-gyp
- nopt
- npm-audit-report
- npm-install-checks
- npm-package-arg
- npm-pick-manifest
- npm-profile
- npm-registry-fetch
- npm-user-validate
- npmlog
- opener
- pacote
- parse-conflict-json
- qrcode-terminal
- read
- read-package-json
- read-package-json-fast
- readdir-scoped-modules
- rimraf
- semver
- ssri
- tar
- text-table
- tiny-relative-date
- treeverse
- validate-npm-package-name
- which
- write-file-atomic
/npm/8.15.1:
resolution: {integrity: sha512-ZjVMjEn+PqdjpZg+VLMFz5lyzh7tW+SBt+KQzvoQC986U/clE897eg7YR0PLYw6RfjTsoPTuB95xQ8ubn9go6Q==}
engines: {node: ^12.13.0 || ^14.15.0 || >=16}
hasBin: true
dev: false
bundledDependencies:
- '@isaacs/string-locale-compare'
- '@npmcli/arborist'
- '@npmcli/ci-detect'
- '@npmcli/config'
- '@npmcli/fs'
- '@npmcli/map-workspaces'
- '@npmcli/package-json'
- '@npmcli/run-script'
- abbrev
- archy
- cacache
- chalk
- chownr
- cli-columns
- cli-table3
- columnify
- fastest-levenshtein
- glob
- graceful-fs
- hosted-git-info
- ini
- init-package-json
- is-cidr
- json-parse-even-better-errors
- libnpmaccess
- libnpmdiff
- libnpmexec
- libnpmfund
- libnpmhook
- libnpmorg
- libnpmpack
- libnpmpublish
- libnpmsearch
- libnpmteam
- libnpmversion
- make-fetch-happen
- minipass
- minipass-pipeline
- mkdirp
- mkdirp-infer-owner
- ms
- node-gyp
- nopt
- npm-audit-report
- npm-install-checks
- npm-package-arg
- npm-pick-manifest
- npm-profile
- npm-registry-fetch
- npm-user-validate
- npmlog
- opener
- p-map
- pacote
- parse-conflict-json
- proc-log
- qrcode-terminal
- read
- read-package-json
- read-package-json-fast
- readdir-scoped-modules
- rimraf
- semver
- ssri
- tar
- text-table
- tiny-relative-date
- treeverse
- validate-npm-package-name
- which
- write-file-atomic
/npmlog/4.1.2:
resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==}
dependencies:
@ -21399,6 +21594,18 @@ packages:
resolution: {integrity: sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==}
dev: false
/pnpm/6.33.1:
resolution: {integrity: sha512-A19nDMOesyc5AjgXbtNk5ILRvwd51OPEn3RDfJgw/YwtNBTHeZmHCftz4b8Ri3rsqANhH04V5kiqyERpYohBxA==}
engines: {node: '>=12.17'}
hasBin: true
dev: false
/pnpm/7.8.0:
resolution: {integrity: sha512-jzb9/gto4nwuVA2itTRk0PJhuaZcA1NBRB298UzXhqKZQMjtHCS+KLzh7RWk5n3g+KnMg5FHr6Mwg1L62dBz1A==}
engines: {node: '>=14.6'}
hasBin: true
dev: false
/popper.js/1.16.1-lts:
resolution: {integrity: sha512-Kjw8nKRl1m+VrSFCoVGPph93W/qrSO7ZkqPpTf7F4bk/sqcfWK019dWBUpE/fBOsOQY1dks/Bmcbfn1heM/IsA==}
dev: false
@ -27740,6 +27947,13 @@ packages:
yargs-parser: 21.0.0
dev: true
/yarn/1.22.19:
resolution: {integrity: sha512-/0V5q0WbslqnwP91tirOvldvYISzaqhClxzyUKXYxs07yUILIs5jx/k6CFe8bvKSkds5w+eiOqta39Wk3WxdcQ==}
engines: {node: '>=4.0.0'}
hasBin: true
requiresBuild: true
dev: false
/yn/3.1.1:
resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
engines: {node: '>=6'}

View file

@ -2,13 +2,5 @@ const { defaults } = require('jest-config');
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {
name: 'verdaccio-e2e-cli-jest',
// verbose: true,
// collectCoverage: false,
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
// testEnvironment: './env_babel.js',
// globalSetup: './env_setup.js',
// globalTeardown: './env_teardown.js',
// testRegex: '(/test/e2e.*\\.spec)\\.ts',
testRegex: '(/test/*.*.spec)\\.ts',
});

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.reference.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./build"
},
"extends": "../../../tsconfig.reference.json",
"references": [
{
"path": "../cli-commons"

View file

@ -7,6 +7,5 @@ export function getCommand() {
}
export function npm(...args: string[]) {
console.log('-getCommand()', getCommand());
return exec({}, getCommand(), args);
}

View file

@ -0,0 +1,3 @@
{
"extends": "../../../.babelrc"
}

View file

@ -0,0 +1,7 @@
{
"rules": {
"no-console": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-member-accessibility": 0
}
}

21
test/cli/e2e-npm7/LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Verdaccio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,48 @@
# E2E CLI Testing
## What is included on these test?
- Default configuration only
- Basic commands eg (`install / add`, `info`, `publish`).
- Test with 3 package managers (`yarn classic`, `pnpm` and `npm@7`)
## How it works?
On run test suites, there is a global setup where will install the local source code of verdaccio in a temporary folder.
Each suite will install.
1. `spawn` a registry on port `6001` using `_bootstrap_verdaccio.yaml` which block any local package being
fetched from remote upstream.
2. Publish local project to the spawned registry (with global `pnpm`)
> The published `verdaccio` should be fetch by each suite to ensure reliability of each test.
## How to write test?
Each of the suite must use a package manager command _(eg: `npm install`)_ and validate the output according what the
user see, either verifying the outcome in JSON form, run a command _(`eg: jest ..`)_ and the expected result.
Each Test should start with the initial setup, this step does the following
- `beforeAll`: Install verdaccio to the suite context that returns a `Setup` object.
- `afterAll`: Stop the child process that runs verdaccio.
```js
beforeAll(async () => {
setup = await initialSetup(tempRootFolder, port);
console.log('--setup', setup.install);
});
```
stop the process is the final step that should occur in every suite.
```js
afterAll(async () => {
setup.child.kill();
});
```
### What should not included on these tests?
- Anything is unrelated with client commands usage, eg: (auth permissions, third party integrations,
hooks, plugins)

View file

@ -0,0 +1,30 @@
import { addRegistry, initialSetup } from '@verdaccio/test-cli-commons';
import { npm } from './utils';
describe('install a package', () => {
jest.setTimeout(10000);
let registry;
beforeAll(async () => {
const setup = await initialSetup();
registry = setup.registry;
await registry.init();
});
test('should run npm info json body', async () => {
const resp = await npm(
'info',
'verdaccio',
'--json',
...addRegistry(registry.getRegistryUrl())
);
const parsedBody = JSON.parse(resp.stdout as string);
expect(parsedBody.name).toEqual('verdaccio');
expect(parsedBody.dependencies).toBeDefined();
});
afterAll(async () => {
registry.stop();
});
});

View file

@ -0,0 +1,6 @@
const { defaults } = require('jest-config');
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
});

View file

@ -0,0 +1,12 @@
{
"private": true,
"name": "@verdaccio/e2e-cli-npm7",
"version": "2.0.0-6-next.1",
"dependencies": {
"@verdaccio/test-cli-commons": "workspace:1.0.0",
"npm": "latest-7"
},
"scripts": {
"test": "jest"
}
}

View file

@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.reference.json",
"references": [
{
"path": "../cli-commons"
}
]
}

View file

@ -0,0 +1,11 @@
import { join } from 'path';
import { exec } from '@verdaccio/test-cli-commons';
export function getCommand() {
return join(__dirname, './node_modules/.bin/npm');
}
export function npm(...args: string[]) {
return exec({}, getCommand(), args);
}

View file

@ -0,0 +1,3 @@
{
"extends": "../../../.babelrc"
}

View file

@ -0,0 +1,7 @@
{
"rules": {
"no-console": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-member-accessibility": 0
}
}

21
test/cli/e2e-npm8/LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Verdaccio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,48 @@
# E2E CLI Testing
## What is included on these test?
- Default configuration only
- Basic commands eg (`install / add`, `info`, `publish`).
- Test with 3 package managers (`yarn classic`, `pnpm` and `npm@7`)
## How it works?
On run test suites, there is a global setup where will install the local source code of verdaccio in a temporary folder.
Each suite will install.
1. `spawn` a registry on port `6001` using `_bootstrap_verdaccio.yaml` which block any local package being
fetched from remote upstream.
2. Publish local project to the spawned registry (with global `pnpm`)
> The published `verdaccio` should be fetch by each suite to ensure reliability of each test.
## How to write test?
Each of the suite must use a package manager command _(eg: `npm install`)_ and validate the output according what the
user see, either verifying the outcome in JSON form, run a command _(`eg: jest ..`)_ and the expected result.
Each Test should start with the initial setup, this step does the following
- `beforeAll`: Install verdaccio to the suite context that returns a `Setup` object.
- `afterAll`: Stop the child process that runs verdaccio.
```js
beforeAll(async () => {
setup = await initialSetup(tempRootFolder, port);
console.log('--setup', setup.install);
});
```
stop the process is the final step that should occur in every suite.
```js
afterAll(async () => {
setup.child.kill();
});
```
### What should not included on these tests?
- Anything is unrelated with client commands usage, eg: (auth permissions, third party integrations,
hooks, plugins)

View file

@ -0,0 +1,30 @@
import { addRegistry, initialSetup } from '@verdaccio/test-cli-commons';
import { npm } from './utils';
describe('install a package', () => {
jest.setTimeout(10000);
let registry;
beforeAll(async () => {
const setup = await initialSetup();
registry = setup.registry;
await registry.init();
});
test('should run npm info json body', async () => {
const resp = await npm(
'info',
'verdaccio',
'--json',
...addRegistry(registry.getRegistryUrl())
);
const parsedBody = JSON.parse(resp.stdout as string);
expect(parsedBody.name).toEqual('verdaccio');
expect(parsedBody.dependencies).toBeDefined();
});
afterAll(async () => {
registry.stop();
});
});

View file

@ -0,0 +1,6 @@
const { defaults } = require('jest-config');
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
});

View file

@ -0,0 +1,12 @@
{
"private": true,
"name": "@verdaccio/e2e-cli-npm8",
"version": "2.0.0-6-next.1",
"dependencies": {
"@verdaccio/test-cli-commons": "workspace:1.0.0",
"npm": "next-8"
},
"scripts": {
"test": "jest"
}
}

View file

@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.reference.json",
"references": [
{
"path": "../cli-commons"
}
]
}

View file

@ -0,0 +1,11 @@
import { join } from 'path';
import { exec } from '@verdaccio/test-cli-commons';
export function getCommand() {
return join(__dirname, './node_modules/.bin/npm');
}
export function npm(...args: string[]) {
return exec({}, getCommand(), args);
}

View file

@ -0,0 +1,3 @@
{
"extends": "../../../.babelrc"
}

View file

@ -0,0 +1,7 @@
{
"rules": {
"no-console": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-member-accessibility": 0
}
}

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Verdaccio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,48 @@
# E2E CLI Testing
## What is included on these test?
- Default configuration only
- Basic commands eg (`install / add`, `info`, `publish`).
- Test with 3 package managers (`yarn classic`, `pnpm` and `npm@7`)
## How it works?
On run test suites, there is a global setup where will install the local source code of verdaccio in a temporary folder.
Each suite will install.
1. `spawn` a registry on port `6001` using `_bootstrap_verdaccio.yaml` which block any local package being
fetched from remote upstream.
2. Publish local project to the spawned registry (with global `pnpm`)
> The published `verdaccio` should be fetch by each suite to ensure reliability of each test.
## How to write test?
Each of the suite must use a package manager command _(eg: `npm install`)_ and validate the output according what the
user see, either verifying the outcome in JSON form, run a command _(`eg: jest ..`)_ and the expected result.
Each Test should start with the initial setup, this step does the following
- `beforeAll`: Install verdaccio to the suite context that returns a `Setup` object.
- `afterAll`: Stop the child process that runs verdaccio.
```js
beforeAll(async () => {
setup = await initialSetup(tempRootFolder, port);
console.log('--setup', setup.install);
});
```
stop the process is the final step that should occur in every suite.
```js
afterAll(async () => {
setup.child.kill();
});
```
### What should not included on these tests?
- Anything is unrelated with client commands usage, eg: (auth permissions, third party integrations,
hooks, plugins)

View file

@ -0,0 +1,30 @@
import { addRegistry, initialSetup } from '@verdaccio/test-cli-commons';
import { npm } from './utils';
describe('install a package', () => {
jest.setTimeout(10000);
let registry;
beforeAll(async () => {
const setup = await initialSetup();
registry = setup.registry;
await registry.init();
});
test('should run pnpm info json body', async () => {
const resp = await npm(
'info',
'verdaccio',
'--json',
...addRegistry(registry.getRegistryUrl())
);
const parsedBody = JSON.parse(resp.stdout as string);
expect(parsedBody.name).toEqual('verdaccio');
expect(parsedBody.dependencies).toBeDefined();
});
afterAll(async () => {
registry.stop();
});
});

View file

@ -0,0 +1,6 @@
const { defaults } = require('jest-config');
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
});

View file

@ -0,0 +1,12 @@
{
"private": true,
"name": "@verdaccio/e2e-cli-pnpm6",
"version": "2.0.0-6-next.1",
"dependencies": {
"@verdaccio/test-cli-commons": "workspace:1.0.0",
"pnpm": "latest-6"
},
"scripts": {
"test": "jest"
}
}

View file

@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.reference.json",
"references": [
{
"path": "../cli-commons"
}
]
}

View file

@ -0,0 +1,11 @@
import { join } from 'path';
import { exec } from '@verdaccio/test-cli-commons';
export function getCommand() {
return join(__dirname, './node_modules/.bin/pnpm');
}
export function npm(...args: string[]) {
return exec({}, getCommand(), args);
}

View file

@ -0,0 +1,3 @@
{
"extends": "../../../.babelrc"
}

View file

@ -0,0 +1,7 @@
{
"rules": {
"no-console": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-member-accessibility": 0
}
}

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Verdaccio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,48 @@
# E2E CLI Testing
## What is included on these test?
- Default configuration only
- Basic commands eg (`install / add`, `info`, `publish`).
- Test with 3 package managers (`yarn classic`, `pnpm` and `npm@7`)
## How it works?
On run test suites, there is a global setup where will install the local source code of verdaccio in a temporary folder.
Each suite will install.
1. `spawn` a registry on port `6001` using `_bootstrap_verdaccio.yaml` which block any local package being
fetched from remote upstream.
2. Publish local project to the spawned registry (with global `pnpm`)
> The published `verdaccio` should be fetch by each suite to ensure reliability of each test.
## How to write test?
Each of the suite must use a package manager command _(eg: `npm install`)_ and validate the output according what the
user see, either verifying the outcome in JSON form, run a command _(`eg: jest ..`)_ and the expected result.
Each Test should start with the initial setup, this step does the following
- `beforeAll`: Install verdaccio to the suite context that returns a `Setup` object.
- `afterAll`: Stop the child process that runs verdaccio.
```js
beforeAll(async () => {
setup = await initialSetup(tempRootFolder, port);
console.log('--setup', setup.install);
});
```
stop the process is the final step that should occur in every suite.
```js
afterAll(async () => {
setup.child.kill();
});
```
### What should not included on these tests?
- Anything is unrelated with client commands usage, eg: (auth permissions, third party integrations,
hooks, plugins)

View file

@ -0,0 +1,30 @@
import { addRegistry, initialSetup } from '@verdaccio/test-cli-commons';
import { npm } from './utils';
describe('install a package', () => {
jest.setTimeout(10000);
let registry;
beforeAll(async () => {
const setup = await initialSetup();
registry = setup.registry;
await registry.init();
});
test('should run pnpm info json body', async () => {
const resp = await npm(
'info',
'verdaccio',
'--json',
...addRegistry(registry.getRegistryUrl())
);
const parsedBody = JSON.parse(resp.stdout as string);
expect(parsedBody.name).toEqual('verdaccio');
expect(parsedBody.dependencies).toBeDefined();
});
afterAll(async () => {
registry.stop();
});
});

View file

@ -0,0 +1,6 @@
const { defaults } = require('jest-config');
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
});

View file

@ -0,0 +1,12 @@
{
"private": true,
"name": "@verdaccio/e2e-cli-pnpm7",
"version": "1.0.0",
"dependencies": {
"@verdaccio/test-cli-commons": "workspace:1.0.0",
"pnpm": "next-7"
},
"scripts": {
"test": "jest"
}
}

View file

@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.reference.json",
"references": [
{
"path": "../cli-commons"
}
]
}

View file

@ -0,0 +1,11 @@
import { join } from 'path';
import { exec } from '@verdaccio/test-cli-commons';
export function getCommand() {
return join(__dirname, './node_modules/.bin/pnpm');
}
export function npm(...args: string[]) {
return exec({}, getCommand(), args);
}

View file

@ -0,0 +1,3 @@
{
"extends": "../../../.babelrc"
}

View file

@ -0,0 +1,7 @@
{
"rules": {
"no-console": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-member-accessibility": 0
}
}

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Verdaccio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,48 @@
# E2E CLI Testing
## What is included on these test?
- Default configuration only
- Basic commands eg (`install / add`, `info`, `publish`).
- Test with 3 package managers (`yarn classic`, `pnpm` and `npm@7`)
## How it works?
On run test suites, there is a global setup where will install the local source code of verdaccio in a temporary folder.
Each suite will install.
1. `spawn` a registry on port `6001` using `_bootstrap_verdaccio.yaml` which block any local package being
fetched from remote upstream.
2. Publish local project to the spawned registry (with global `pnpm`)
> The published `verdaccio` should be fetch by each suite to ensure reliability of each test.
## How to write test?
Each of the suite must use a package manager command _(eg: `npm install`)_ and validate the output according what the
user see, either verifying the outcome in JSON form, run a command _(`eg: jest ..`)_ and the expected result.
Each Test should start with the initial setup, this step does the following
- `beforeAll`: Install verdaccio to the suite context that returns a `Setup` object.
- `afterAll`: Stop the child process that runs verdaccio.
```js
beforeAll(async () => {
setup = await initialSetup(tempRootFolder, port);
console.log('--setup', setup.install);
});
```
stop the process is the final step that should occur in every suite.
```js
afterAll(async () => {
setup.child.kill();
});
```
### What should not included on these tests?
- Anything is unrelated with client commands usage, eg: (auth permissions, third party integrations,
hooks, plugins)

View file

@ -0,0 +1,31 @@
import { addRegistry, initialSetup } from '@verdaccio/test-cli-commons';
import { yarn } from './utils';
describe('install a package', () => {
jest.setTimeout(10000);
let registry;
beforeAll(async () => {
const setup = await initialSetup();
registry = setup.registry;
await registry.init();
});
test('should run yarn info json body', async () => {
const resp = await yarn(
'info',
'verdaccio',
'--json',
...addRegistry(registry.getRegistryUrl())
);
const parsedBody = JSON.parse(resp.stdout as string);
expect(parsedBody.data.name).toEqual('verdaccio');
expect(parsedBody.data.dependencies).toBeDefined();
});
afterAll(async () => {
registry.stop();
});
});

View file

@ -0,0 +1,14 @@
const { defaults } = require('jest-config');
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {
name: 'verdaccio-e2e-cli-jest',
// verbose: true,
// collectCoverage: false,
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
// testEnvironment: './env_babel.js',
// globalSetup: './env_setup.js',
// globalTeardown: './env_teardown.js',
// testRegex: '(/test/e2e.*\\.spec)\\.ts',
testRegex: '(/test/*.*.spec)\\.ts',
});

View file

@ -0,0 +1,12 @@
{
"private": true,
"name": "@verdaccio/e2e-cli-yarn1",
"version": "2.0.0-6-next.1",
"dependencies": {
"@verdaccio/test-cli-commons": "workspace:1.0.0",
"yarn": "1.22.19"
},
"scripts": {
"test": "jest"
}
}

View file

@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.reference.json",
"references": [
{
"path": "../cli-commons"
}
]
}

View file

@ -0,0 +1,11 @@
import { join } from 'path';
import { exec } from '@verdaccio/test-cli-commons';
export function getCommand() {
return join(__dirname, './node_modules/.bin/yarn');
}
export function yarn(...args: string[]) {
return exec({}, getCommand(), args);
}

View file

@ -1,15 +1,9 @@
{
"rules": {
"no-console": 0,
"new-cap": 0,
"max-len": 0
},
"globals": {
"VERDACCIO_API_URL": true,
"__DEBUG__": true
},
"env": {
"browser": true,
"jest/globals": true
"browser": true
}
}

View file

@ -21,6 +21,7 @@ describe('basic functionality', () => {
page = await global.__BROWSER__.newPage();
await page.goto(`http://0.0.0.0:${registry1.getPort()}`);
// eslint-disable-next-line no-console
page.on('console', (msg) => console.log('PAGE LOG:', msg.text()));
});

View file

@ -26,6 +26,7 @@ describe('/ (Verdaccio Page)', () => {
page = await global.__BROWSER__.newPage();
await page.goto(`http://0.0.0.0:${registry1.getPort()}`);
// eslint-disable-next-line no-console
page.on('console', (msg) => console.log('PAGE LOG:', msg.text()));
});
@ -39,7 +40,6 @@ describe('/ (Verdaccio Page)', () => {
test('should publish a package', async () => {
const server = new ServerQuery(registry1.getRegistryUrl());
console.log('-registry1.getToken()', registry1.getToken());
await server.putPackage(scopedPackageMetadata.name, scopedPackageMetadata, {
[HEADERS.AUTHORIZATION]: `Bearer ${registry1.getToken()}`,
});

View file

@ -8,6 +8,7 @@ const puppeteer = require('puppeteer');
const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
module.exports = async function () {
// eslint-disable-next-line no-console
console.log(green('Setup Puppeteer'));
const browser = await puppeteer.launch({
isMobile: false,

View file

@ -22,6 +22,7 @@ describe('sign in user', () => {
page = await global.__BROWSER__.newPage();
await page.goto(`http://0.0.0.0:${registry1.getPort()}`);
// eslint-disable-next-line no-console
page.on('console', (msg) => console.log('PAGE LOG:', msg.text()));
});

View file

@ -7,6 +7,7 @@ const rimraf = require('rimraf');
const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
module.exports = async function () {
// eslint-disable-next-line no-console
console.log(green('Teardown Puppeteer'));
await global.__BROWSER__.close();
rimraf.sync(DIR);