From b28e6f737b929208a415e276ed5f6d68790d4e3b Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Sun, 17 Jun 2018 16:00:36 +0200 Subject: [PATCH] refactor: functional testing relocation functional testing runs in a different process --- .npmignore | 51 ++++++++++++------- jest.config.js => jest.config.unit.js | 4 +- package.json | 6 +-- .../basic/{basic.spec.js => basic.js} | 0 .../{index.func.js => index.spec.js} | 22 ++++---- .../package/{access.spec.js => access.js} | 0 .../package/{gzip.spec.js => gzip.js} | 0 .../package/{scoped.spec.js => scoped.js} | 0 .../plugins/{auth.spec.js => auth.js} | 0 .../{middleware.spec.js => middleware.js} | 0 .../readme/{readme.spec.js => readme.js} | 0 .../tags/{addtag.spec.js => addtag.js} | 0 ...preserve_tags.spec.js => preserve_tags.js} | 0 .../functional/tags/{tags.spec.js => tags.js} | 0 .../{uplink.auth.spec.js => uplink.auth.js} | 0 .../{uplink.cache.spec.js => uplink.cache.js} | 0 test/jest.config.func.js | 8 +++ 17 files changed, 57 insertions(+), 34 deletions(-) rename jest.config.js => jest.config.unit.js (85%) rename test/functional/basic/{basic.spec.js => basic.js} (100%) rename test/functional/{index.func.js => index.spec.js} (87%) rename test/functional/package/{access.spec.js => access.js} (100%) rename test/functional/package/{gzip.spec.js => gzip.js} (100%) rename test/functional/package/{scoped.spec.js => scoped.js} (100%) rename test/functional/plugins/{auth.spec.js => auth.js} (100%) rename test/functional/plugins/{middleware.spec.js => middleware.js} (100%) rename test/functional/readme/{readme.spec.js => readme.js} (100%) rename test/functional/tags/{addtag.spec.js => addtag.js} (100%) rename test/functional/tags/{preserve_tags.spec.js => preserve_tags.js} (100%) rename test/functional/tags/{tags.spec.js => tags.js} (100%) rename test/functional/{uplink.auth.spec.js => uplink.auth.js} (100%) rename test/functional/{uplink.cache.spec.js => uplink.cache.js} (100%) create mode 100644 test/jest.config.func.js diff --git a/.npmignore b/.npmignore index c3b06b3a4..5bcebb427 100644 --- a/.npmignore +++ b/.npmignore @@ -1,30 +1,45 @@ -node_modules + +## npm npm-debug.log -renovate.json yarn-error.log +node_modules +verdaccio-*.tgz + +renovate.json docker-compose.yaml Dockerfile.rpi Dockerfile -circle.yml crowdin.yaml -coverage/ -verdaccio-*.tgz -test-storage* scripts/ -docs/ src/ -tools/ /.* .vscode/ -website/ -assets/ -flow-typed/ -__mocks__/ -test/ -types/ -wiki/ -jestEnvironment.js -test/e2e/jest.e2e.config.js -jest.config.js +.circleci/ debug/ +# build ui +tools/ + +## assets and website +assets/ +website/ + +## docs +docs/ +wiki/ + +## flow +flow-typed/ +types/ + +# jest +coverage/ +test-storage* +test/ +__mocks__/ +jestEnvironment.js +test/e2e/jest.e2e.config.js +test/jest.config.func.js +jest.config.unit.js + + diff --git a/jest.config.js b/jest.config.unit.js similarity index 85% rename from jest.config.js rename to jest.config.unit.js index e6b3da7e6..d341397b2 100644 --- a/jest.config.js +++ b/jest.config.unit.js @@ -1,7 +1,7 @@ /* eslint comma-dangle: 0 */ module.exports = { - name: 'verdaccio-jest', + name: 'verdaccio-unit-jest', verbose: true, collectCoverage: true, coveragePathIgnorePatterns: [ @@ -9,7 +9,7 @@ module.exports = { 'fixtures' ], testEnvironment: 'jest-environment-jsdom-global', - testRegex: '(/test/unit.*\\.spec|test/functional.*\\.func|/test/unit/webui/.*\\.spec)\\.js', + testRegex: '(test/unit.*\\.spec|test/unit/webui/.*\\.spec)\\.js', setupFiles: [ './test/unit/setup-webui.js' ], diff --git a/package.json b/package.json index 525e59eab..f00d0e160 100644 --- a/package.json +++ b/package.json @@ -154,9 +154,9 @@ "prepublish": "in-publish && npm run build:webui && npm run code:build || not-in-publish", "flow": "flow", "pretest": "npm run code:build", - "test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --maxWorkers 2", - "test:unit": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest '(/test/unit.*\\.spec|/test/webui/.*\\.spec)\\.js' --maxWorkers 2", - "test:func": "cross-env NODE_ENV=test BABEL_ENV=test jest '(/test/functional.*\\.func)\\.js' --maxWorkers 2", + "test": "cross-env npm run test:unit && npm run test:func", + "test:unit": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest.config.unit.js --maxWorkers 2", + "test:func": "cross-env NODE_ENV=test BABEL_ENV=test jest --config ./test/jest.config.func.js --testPathPattern ./test/functional/index*", "test:e2e": "cross-env BABEL_ENV=testE2E jest --config ./test/e2e/jest.e2e.config.js --maxWorkers 2", "test:all": "npm run test && npm run test:e2e", "pre:ci": "npm run lint && npm run build:webui", diff --git a/test/functional/basic/basic.spec.js b/test/functional/basic/basic.js similarity index 100% rename from test/functional/basic/basic.spec.js rename to test/functional/basic/basic.js diff --git a/test/functional/index.func.js b/test/functional/index.spec.js similarity index 87% rename from test/functional/index.func.js rename to test/functional/index.spec.js index c7969da22..6bcfbbad4 100644 --- a/test/functional/index.func.js +++ b/test/functional/index.spec.js @@ -12,27 +12,27 @@ import ExpressServer from './lib/simple_server'; import Server from '../lib/server'; import type {IServerProcess, IServerBridge} from '../types'; -import basic from './basic/basic.spec'; -import packageAccess from './package/access.spec'; -import packageGzip from './package/gzip.spec'; -import packageScoped from './package/scoped.spec'; -import tags from './tags/tags.spec'; -import preserveTags from './tags/preserve_tags.spec'; -import addtag from './tags/addtag.spec'; +import basic from './basic/basic'; +import packageAccess from './package/access'; +import packageGzip from './package/gzip'; +import packageScoped from './package/scoped'; +import tags from './tags/tags'; +import preserveTags from './tags/preserve_tags'; +import addtag from './tags/addtag'; import adduser from './adduser/adduser'; import logout from './adduser/logout'; import notify from './notifications/notify'; import incomplete from './sanity/incomplete'; import mirror from './sanity/mirror'; -import readme from './readme/readme.spec'; +import readme from './readme/readme'; import gh29 from './gh29'; import nullstorage from './sanity/nullstorage'; import racycrash from './sanity/racycrash'; import security from './sanity/security'; import race from './performance/race'; -import pluginsAuth from './plugins/auth.spec'; -import upLinkCache from './uplink.cache.spec'; -import upLinkAuth from './uplink.auth.spec'; +import pluginsAuth from './plugins/auth'; +import upLinkCache from './uplink.cache'; +import upLinkAuth from './uplink.auth'; describe('functional test verdaccio', function() { jest.setTimeout(10000); diff --git a/test/functional/package/access.spec.js b/test/functional/package/access.js similarity index 100% rename from test/functional/package/access.spec.js rename to test/functional/package/access.js diff --git a/test/functional/package/gzip.spec.js b/test/functional/package/gzip.js similarity index 100% rename from test/functional/package/gzip.spec.js rename to test/functional/package/gzip.js diff --git a/test/functional/package/scoped.spec.js b/test/functional/package/scoped.js similarity index 100% rename from test/functional/package/scoped.spec.js rename to test/functional/package/scoped.js diff --git a/test/functional/plugins/auth.spec.js b/test/functional/plugins/auth.js similarity index 100% rename from test/functional/plugins/auth.spec.js rename to test/functional/plugins/auth.js diff --git a/test/functional/plugins/middleware.spec.js b/test/functional/plugins/middleware.js similarity index 100% rename from test/functional/plugins/middleware.spec.js rename to test/functional/plugins/middleware.js diff --git a/test/functional/readme/readme.spec.js b/test/functional/readme/readme.js similarity index 100% rename from test/functional/readme/readme.spec.js rename to test/functional/readme/readme.js diff --git a/test/functional/tags/addtag.spec.js b/test/functional/tags/addtag.js similarity index 100% rename from test/functional/tags/addtag.spec.js rename to test/functional/tags/addtag.js diff --git a/test/functional/tags/preserve_tags.spec.js b/test/functional/tags/preserve_tags.js similarity index 100% rename from test/functional/tags/preserve_tags.spec.js rename to test/functional/tags/preserve_tags.js diff --git a/test/functional/tags/tags.spec.js b/test/functional/tags/tags.js similarity index 100% rename from test/functional/tags/tags.spec.js rename to test/functional/tags/tags.js diff --git a/test/functional/uplink.auth.spec.js b/test/functional/uplink.auth.js similarity index 100% rename from test/functional/uplink.auth.spec.js rename to test/functional/uplink.auth.js diff --git a/test/functional/uplink.cache.spec.js b/test/functional/uplink.cache.js similarity index 100% rename from test/functional/uplink.cache.spec.js rename to test/functional/uplink.cache.js diff --git a/test/jest.config.func.js b/test/jest.config.func.js new file mode 100644 index 000000000..cc872389e --- /dev/null +++ b/test/jest.config.func.js @@ -0,0 +1,8 @@ +/* eslint comma-dangle: 0 */ + +module.exports = { + name: 'verdaccio-func-jest', + verbose: true, + collectCoverage: false, + testPathPattern: 'test/functional/functional.spec.js' +};