diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 160aa2721..f4360ce23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ on: - .changeset/** - .github/workflows/ci.yml - 'packages/**' + - 'test/**' - 'docker-examples/**' - 'jest/**' - 'package.json' diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f54007323..b57ab739e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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'} diff --git a/test/cli/e2e-npm6/jest.config.js b/test/cli/e2e-npm6/jest.config.js index 757434d39..56618976e 100644 --- a/test/cli/e2e-npm6/jest.config.js +++ b/test/cli/e2e-npm6/jest.config.js @@ -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', }); diff --git a/test/cli/e2e-npm6/tsconfig.json b/test/cli/e2e-npm6/tsconfig.json index 08e267c67..85f4ceca6 100644 --- a/test/cli/e2e-npm6/tsconfig.json +++ b/test/cli/e2e-npm6/tsconfig.json @@ -1,9 +1,5 @@ { - "extends": "../../tsconfig.reference.json", - "compilerOptions": { - "rootDir": "./src", - "outDir": "./build" - }, + "extends": "../../../tsconfig.reference.json", "references": [ { "path": "../cli-commons" diff --git a/test/cli/e2e-npm6/utils.ts b/test/cli/e2e-npm6/utils.ts index 12a867dd3..9fbda5332 100644 --- a/test/cli/e2e-npm6/utils.ts +++ b/test/cli/e2e-npm6/utils.ts @@ -7,6 +7,5 @@ export function getCommand() { } export function npm(...args: string[]) { - console.log('-getCommand()', getCommand()); return exec({}, getCommand(), args); } diff --git a/test/cli/e2e-npm7/.babelrc b/test/cli/e2e-npm7/.babelrc new file mode 100644 index 000000000..851856e59 --- /dev/null +++ b/test/cli/e2e-npm7/.babelrc @@ -0,0 +1,3 @@ +{ + "extends": "../../../.babelrc" +} diff --git a/test/cli/e2e-npm7/.eslintrc b/test/cli/e2e-npm7/.eslintrc new file mode 100644 index 000000000..eb2ac4c85 --- /dev/null +++ b/test/cli/e2e-npm7/.eslintrc @@ -0,0 +1,7 @@ +{ + "rules": { + "no-console": 0, + "@typescript-eslint/no-var-requires": 0, + "@typescript-eslint/explicit-member-accessibility": 0 + } +} diff --git a/test/cli/e2e-npm7/LICENSE b/test/cli/e2e-npm7/LICENSE new file mode 100644 index 000000000..a23b4d909 --- /dev/null +++ b/test/cli/e2e-npm7/LICENSE @@ -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. diff --git a/test/cli/e2e-npm7/README.md b/test/cli/e2e-npm7/README.md new file mode 100644 index 000000000..e942b766f --- /dev/null +++ b/test/cli/e2e-npm7/README.md @@ -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) diff --git a/test/cli/e2e-npm7/info.spec.ts b/test/cli/e2e-npm7/info.spec.ts new file mode 100644 index 000000000..13245890e --- /dev/null +++ b/test/cli/e2e-npm7/info.spec.ts @@ -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(); + }); +}); diff --git a/test/cli/e2e-npm7/jest.config.js b/test/cli/e2e-npm7/jest.config.js new file mode 100644 index 000000000..56618976e --- /dev/null +++ b/test/cli/e2e-npm7/jest.config.js @@ -0,0 +1,6 @@ +const { defaults } = require('jest-config'); +const config = require('../../../jest/config'); + +module.exports = Object.assign({}, config, { + moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'], +}); diff --git a/test/cli/e2e-npm7/package.json b/test/cli/e2e-npm7/package.json new file mode 100644 index 000000000..b98737674 --- /dev/null +++ b/test/cli/e2e-npm7/package.json @@ -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" + } +} diff --git a/test/cli/e2e-npm7/tsconfig.json b/test/cli/e2e-npm7/tsconfig.json new file mode 100644 index 000000000..85f4ceca6 --- /dev/null +++ b/test/cli/e2e-npm7/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.reference.json", + "references": [ + { + "path": "../cli-commons" + } + ] +} diff --git a/test/cli/e2e-npm7/utils.ts b/test/cli/e2e-npm7/utils.ts new file mode 100644 index 000000000..9fbda5332 --- /dev/null +++ b/test/cli/e2e-npm7/utils.ts @@ -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); +} diff --git a/test/cli/e2e-npm8/.babelrc b/test/cli/e2e-npm8/.babelrc new file mode 100644 index 000000000..851856e59 --- /dev/null +++ b/test/cli/e2e-npm8/.babelrc @@ -0,0 +1,3 @@ +{ + "extends": "../../../.babelrc" +} diff --git a/test/cli/e2e-npm8/.eslintrc b/test/cli/e2e-npm8/.eslintrc new file mode 100644 index 000000000..eb2ac4c85 --- /dev/null +++ b/test/cli/e2e-npm8/.eslintrc @@ -0,0 +1,7 @@ +{ + "rules": { + "no-console": 0, + "@typescript-eslint/no-var-requires": 0, + "@typescript-eslint/explicit-member-accessibility": 0 + } +} diff --git a/test/cli/e2e-npm8/LICENSE b/test/cli/e2e-npm8/LICENSE new file mode 100644 index 000000000..a23b4d909 --- /dev/null +++ b/test/cli/e2e-npm8/LICENSE @@ -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. diff --git a/test/cli/e2e-npm8/README.md b/test/cli/e2e-npm8/README.md new file mode 100644 index 000000000..e942b766f --- /dev/null +++ b/test/cli/e2e-npm8/README.md @@ -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) diff --git a/test/cli/e2e-npm8/info.spec.ts b/test/cli/e2e-npm8/info.spec.ts new file mode 100644 index 000000000..13245890e --- /dev/null +++ b/test/cli/e2e-npm8/info.spec.ts @@ -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(); + }); +}); diff --git a/test/cli/e2e-npm8/jest.config.js b/test/cli/e2e-npm8/jest.config.js new file mode 100644 index 000000000..56618976e --- /dev/null +++ b/test/cli/e2e-npm8/jest.config.js @@ -0,0 +1,6 @@ +const { defaults } = require('jest-config'); +const config = require('../../../jest/config'); + +module.exports = Object.assign({}, config, { + moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'], +}); diff --git a/test/cli/e2e-npm8/package.json b/test/cli/e2e-npm8/package.json new file mode 100644 index 000000000..fb8b14373 --- /dev/null +++ b/test/cli/e2e-npm8/package.json @@ -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" + } +} diff --git a/test/cli/e2e-npm8/tsconfig.json b/test/cli/e2e-npm8/tsconfig.json new file mode 100644 index 000000000..85f4ceca6 --- /dev/null +++ b/test/cli/e2e-npm8/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.reference.json", + "references": [ + { + "path": "../cli-commons" + } + ] +} diff --git a/test/cli/e2e-npm8/utils.ts b/test/cli/e2e-npm8/utils.ts new file mode 100644 index 000000000..9fbda5332 --- /dev/null +++ b/test/cli/e2e-npm8/utils.ts @@ -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); +} diff --git a/test/cli/e2e-pnpm6/.babelrc b/test/cli/e2e-pnpm6/.babelrc new file mode 100644 index 000000000..851856e59 --- /dev/null +++ b/test/cli/e2e-pnpm6/.babelrc @@ -0,0 +1,3 @@ +{ + "extends": "../../../.babelrc" +} diff --git a/test/cli/e2e-pnpm6/.eslintrc b/test/cli/e2e-pnpm6/.eslintrc new file mode 100644 index 000000000..eb2ac4c85 --- /dev/null +++ b/test/cli/e2e-pnpm6/.eslintrc @@ -0,0 +1,7 @@ +{ + "rules": { + "no-console": 0, + "@typescript-eslint/no-var-requires": 0, + "@typescript-eslint/explicit-member-accessibility": 0 + } +} diff --git a/test/cli/e2e-pnpm6/LICENSE b/test/cli/e2e-pnpm6/LICENSE new file mode 100644 index 000000000..a23b4d909 --- /dev/null +++ b/test/cli/e2e-pnpm6/LICENSE @@ -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. diff --git a/test/cli/e2e-pnpm6/README.md b/test/cli/e2e-pnpm6/README.md new file mode 100644 index 000000000..e942b766f --- /dev/null +++ b/test/cli/e2e-pnpm6/README.md @@ -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) diff --git a/test/cli/e2e-pnpm6/info.spec.ts b/test/cli/e2e-pnpm6/info.spec.ts new file mode 100644 index 000000000..a14b479ed --- /dev/null +++ b/test/cli/e2e-pnpm6/info.spec.ts @@ -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(); + }); +}); diff --git a/test/cli/e2e-pnpm6/jest.config.js b/test/cli/e2e-pnpm6/jest.config.js new file mode 100644 index 000000000..56618976e --- /dev/null +++ b/test/cli/e2e-pnpm6/jest.config.js @@ -0,0 +1,6 @@ +const { defaults } = require('jest-config'); +const config = require('../../../jest/config'); + +module.exports = Object.assign({}, config, { + moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'], +}); diff --git a/test/cli/e2e-pnpm6/package.json b/test/cli/e2e-pnpm6/package.json new file mode 100644 index 000000000..63aa39440 --- /dev/null +++ b/test/cli/e2e-pnpm6/package.json @@ -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" + } +} diff --git a/test/cli/e2e-pnpm6/tsconfig.json b/test/cli/e2e-pnpm6/tsconfig.json new file mode 100644 index 000000000..85f4ceca6 --- /dev/null +++ b/test/cli/e2e-pnpm6/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.reference.json", + "references": [ + { + "path": "../cli-commons" + } + ] +} diff --git a/test/cli/e2e-pnpm6/utils.ts b/test/cli/e2e-pnpm6/utils.ts new file mode 100644 index 000000000..518007986 --- /dev/null +++ b/test/cli/e2e-pnpm6/utils.ts @@ -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); +} diff --git a/test/cli/e2e-pnpm7/.babelrc b/test/cli/e2e-pnpm7/.babelrc new file mode 100644 index 000000000..851856e59 --- /dev/null +++ b/test/cli/e2e-pnpm7/.babelrc @@ -0,0 +1,3 @@ +{ + "extends": "../../../.babelrc" +} diff --git a/test/cli/e2e-pnpm7/.eslintrc b/test/cli/e2e-pnpm7/.eslintrc new file mode 100644 index 000000000..eb2ac4c85 --- /dev/null +++ b/test/cli/e2e-pnpm7/.eslintrc @@ -0,0 +1,7 @@ +{ + "rules": { + "no-console": 0, + "@typescript-eslint/no-var-requires": 0, + "@typescript-eslint/explicit-member-accessibility": 0 + } +} diff --git a/test/cli/e2e-pnpm7/LICENSE b/test/cli/e2e-pnpm7/LICENSE new file mode 100644 index 000000000..a23b4d909 --- /dev/null +++ b/test/cli/e2e-pnpm7/LICENSE @@ -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. diff --git a/test/cli/e2e-pnpm7/README.md b/test/cli/e2e-pnpm7/README.md new file mode 100644 index 000000000..e942b766f --- /dev/null +++ b/test/cli/e2e-pnpm7/README.md @@ -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) diff --git a/test/cli/e2e-pnpm7/info.spec.ts b/test/cli/e2e-pnpm7/info.spec.ts new file mode 100644 index 000000000..a14b479ed --- /dev/null +++ b/test/cli/e2e-pnpm7/info.spec.ts @@ -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(); + }); +}); diff --git a/test/cli/e2e-pnpm7/jest.config.js b/test/cli/e2e-pnpm7/jest.config.js new file mode 100644 index 000000000..56618976e --- /dev/null +++ b/test/cli/e2e-pnpm7/jest.config.js @@ -0,0 +1,6 @@ +const { defaults } = require('jest-config'); +const config = require('../../../jest/config'); + +module.exports = Object.assign({}, config, { + moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'], +}); diff --git a/test/cli/e2e-pnpm7/package.json b/test/cli/e2e-pnpm7/package.json new file mode 100644 index 000000000..80e66b433 --- /dev/null +++ b/test/cli/e2e-pnpm7/package.json @@ -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" + } +} diff --git a/test/cli/e2e-pnpm7/tsconfig.json b/test/cli/e2e-pnpm7/tsconfig.json new file mode 100644 index 000000000..85f4ceca6 --- /dev/null +++ b/test/cli/e2e-pnpm7/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.reference.json", + "references": [ + { + "path": "../cli-commons" + } + ] +} diff --git a/test/cli/e2e-pnpm7/utils.ts b/test/cli/e2e-pnpm7/utils.ts new file mode 100644 index 000000000..518007986 --- /dev/null +++ b/test/cli/e2e-pnpm7/utils.ts @@ -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); +} diff --git a/test/cli/e2e-yarn1/.babelrc b/test/cli/e2e-yarn1/.babelrc new file mode 100644 index 000000000..851856e59 --- /dev/null +++ b/test/cli/e2e-yarn1/.babelrc @@ -0,0 +1,3 @@ +{ + "extends": "../../../.babelrc" +} diff --git a/test/cli/e2e-yarn1/.eslintrc b/test/cli/e2e-yarn1/.eslintrc new file mode 100644 index 000000000..eb2ac4c85 --- /dev/null +++ b/test/cli/e2e-yarn1/.eslintrc @@ -0,0 +1,7 @@ +{ + "rules": { + "no-console": 0, + "@typescript-eslint/no-var-requires": 0, + "@typescript-eslint/explicit-member-accessibility": 0 + } +} diff --git a/test/cli/e2e-yarn1/LICENSE b/test/cli/e2e-yarn1/LICENSE new file mode 100644 index 000000000..a23b4d909 --- /dev/null +++ b/test/cli/e2e-yarn1/LICENSE @@ -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. diff --git a/test/cli/e2e-yarn1/README.md b/test/cli/e2e-yarn1/README.md new file mode 100644 index 000000000..e942b766f --- /dev/null +++ b/test/cli/e2e-yarn1/README.md @@ -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) diff --git a/test/cli/e2e-npm6/config/_bootstrap_verdaccio.yaml b/test/cli/e2e-yarn1/config/_bootstrap_verdaccio.yaml similarity index 100% rename from test/cli/e2e-npm6/config/_bootstrap_verdaccio.yaml rename to test/cli/e2e-yarn1/config/_bootstrap_verdaccio.yaml diff --git a/test/cli/e2e-npm6/config/default.yaml b/test/cli/e2e-yarn1/config/default.yaml similarity index 100% rename from test/cli/e2e-npm6/config/default.yaml rename to test/cli/e2e-yarn1/config/default.yaml diff --git a/test/cli/e2e-yarn1/info.spec.ts b/test/cli/e2e-yarn1/info.spec.ts new file mode 100644 index 000000000..60e8645f9 --- /dev/null +++ b/test/cli/e2e-yarn1/info.spec.ts @@ -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(); + }); +}); diff --git a/test/cli/e2e-yarn1/jest.config.js b/test/cli/e2e-yarn1/jest.config.js new file mode 100644 index 000000000..757434d39 --- /dev/null +++ b/test/cli/e2e-yarn1/jest.config.js @@ -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', +}); diff --git a/test/cli/e2e-yarn1/package.json b/test/cli/e2e-yarn1/package.json new file mode 100644 index 000000000..a71e2d669 --- /dev/null +++ b/test/cli/e2e-yarn1/package.json @@ -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" + } +} diff --git a/test/cli/e2e-yarn1/tsconfig.json b/test/cli/e2e-yarn1/tsconfig.json new file mode 100644 index 000000000..85f4ceca6 --- /dev/null +++ b/test/cli/e2e-yarn1/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.reference.json", + "references": [ + { + "path": "../cli-commons" + } + ] +} diff --git a/test/cli/e2e-yarn1/utils.ts b/test/cli/e2e-yarn1/utils.ts new file mode 100644 index 000000000..6d978bc53 --- /dev/null +++ b/test/cli/e2e-yarn1/utils.ts @@ -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); +} diff --git a/test/e2e-ui/.eslintrc b/test/e2e-ui/.eslintrc index 3811bf06c..619523212 100644 --- a/test/e2e-ui/.eslintrc +++ b/test/e2e-ui/.eslintrc @@ -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 } } diff --git a/test/e2e-ui/basic.spec.js b/test/e2e-ui/basic.spec.js index a9a12d5ff..901888c03 100644 --- a/test/e2e-ui/basic.spec.js +++ b/test/e2e-ui/basic.spec.js @@ -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())); }); diff --git a/test/e2e-ui/publish.spec.js b/test/e2e-ui/publish.spec.js index 4e11a8d26..1d4b78e99 100644 --- a/test/e2e-ui/publish.spec.js +++ b/test/e2e-ui/publish.spec.js @@ -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()}`, }); diff --git a/test/e2e-ui/setup.js b/test/e2e-ui/setup.js index 15e00b6eb..18a26c41f 100644 --- a/test/e2e-ui/setup.js +++ b/test/e2e-ui/setup.js @@ -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, diff --git a/test/e2e-ui/sigin.spec.js b/test/e2e-ui/sigin.spec.js index 6ee99e08f..b9b89e40f 100644 --- a/test/e2e-ui/sigin.spec.js +++ b/test/e2e-ui/sigin.spec.js @@ -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())); }); diff --git a/test/e2e-ui/teardown.js b/test/e2e-ui/teardown.js index eea6366b4..aeea17034 100644 --- a/test/e2e-ui/teardown.js +++ b/test/e2e-ui/teardown.js @@ -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);