From f4c172419c1a5326d4ce33f51124df7755438a00 Mon Sep 17 00:00:00 2001 From: mmarkelov Date: Tue, 11 Feb 2020 15:03:51 +0300 Subject: [PATCH 1/3] All browsers in parallel --- src/parallel.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/parallel.js diff --git a/src/parallel.js b/src/parallel.js new file mode 100644 index 00000000..26a73c05 --- /dev/null +++ b/src/parallel.js @@ -0,0 +1,16 @@ +import { spawn } from 'child_process' + +const exec = (browser = 'chromium') => { + spawn('node', ['node_modules/.bin/jest'], { + stdio: 'inherit', + shell: true, + env: { + ...process.env, + BROWSER: browser, + }, + }) +} + +exec() +exec('firefox') +exec('webkit') From 845a1cfba568af0dc2627a30b4230167dae7a609 Mon Sep 17 00:00:00 2001 From: mmarkelov Date: Wed, 12 Feb 2020 11:50:09 +0300 Subject: [PATCH 2/3] Rewrite and simplify logic to support running multiple browsers --- package-lock.json | 129 ++++++++++++++++++++++------------------- package.json | 5 +- src/bin/index.js | 13 +++++ src/bin/testProcess.js | 31 ++++++++++ src/bin/utils.js | 11 ++++ src/constants.js | 2 + src/parallel.js | 16 ----- 7 files changed, 129 insertions(+), 78 deletions(-) create mode 100644 src/bin/index.js create mode 100644 src/bin/testProcess.js create mode 100644 src/bin/utils.js delete mode 100644 src/parallel.js diff --git a/package-lock.json b/package-lock.json index 49336789..15c686d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jest-playwright-preset", - "version": "0.0.5", + "version": "0.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1376,7 +1376,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", - "dev": true, + "optional": true, "requires": { "es6-promisify": "^5.0.0" } @@ -1532,7 +1532,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", - "dev": true + "optional": true }, "asynckit": { "version": "0.4.0", @@ -1632,8 +1632,7 @@ "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "base": { "version": "0.11.2", @@ -1720,7 +1719,6 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1781,8 +1779,7 @@ "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, "cache-base": { "version": "1.0.1", @@ -2746,14 +2743,13 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, + "optional": true, "requires": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", @@ -2809,8 +2805,7 @@ "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cosmiconfig": { "version": "6.0.0", @@ -2911,7 +2906,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, "requires": { "ms": "^2.1.1" } @@ -3106,13 +3100,13 @@ "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "dev": true + "optional": true }, "es6-promisify": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", - "dev": true, + "optional": true, "requires": { "es6-promise": "^4.0.3" } @@ -3730,7 +3724,7 @@ "version": "1.6.7", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", - "dev": true, + "optional": true, "requires": { "concat-stream": "1.6.2", "debug": "2.6.9", @@ -3742,7 +3736,7 @@ "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, + "optional": true, "requires": { "ms": "2.0.0" } @@ -3751,7 +3745,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "optional": true } } }, @@ -3798,7 +3792,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", - "dev": true, + "optional": true, "requires": { "pend": "~1.2.0" } @@ -3925,8 +3919,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { "version": "2.1.2", @@ -3999,7 +3992,6 @@ "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -4193,7 +4185,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz", "integrity": "sha512-+ML2Rbh6DAuee7d07tYGEKOEi2voWPUGan+ExdPbPW6Z3svq+JCqr0v8WmKPOkz1vOVykPCBSuobe7G8GJUtVg==", - "dev": true, + "optional": true, "requires": { "agent-base": "^4.3.0", "debug": "^3.1.0" @@ -4203,7 +4195,7 @@ "version": "3.2.6", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, + "optional": true, "requires": { "ms": "^2.1.1" } @@ -4293,7 +4285,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -4302,8 +4293,7 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "inquirer": { "version": "7.0.4", @@ -4637,8 +4627,7 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "isexe": { "version": "2.0.0", @@ -5223,7 +5212,7 @@ "version": "0.3.6", "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.3.6.tgz", "integrity": "sha512-MUj2XlMB8kpe+8DJUGH/3UJm4XpI8XEgZQ+CiHDeyrGoKPdW/8FJv6ku+3UiYm5Fz3CWaL+iXmD8Q4Ap6aC1Jw==", - "dev": true + "optional": true }, "js-tokens": { "version": "4.0.0", @@ -5989,7 +5978,7 @@ "version": "2.4.4", "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==", - "dev": true + "optional": true }, "mime-db": { "version": "1.43.0", @@ -6016,7 +6005,6 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -6024,8 +6012,7 @@ "minimist": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, "mixin-deep": { "version": "1.3.2", @@ -6052,7 +6039,6 @@ "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, "requires": { "minimist": "0.0.8" } @@ -6060,8 +6046,7 @@ "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "mute-stream": { "version": "0.0.8", @@ -6321,7 +6306,6 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "requires": { "wrappy": "1" } @@ -6449,8 +6433,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-key": { "version": "2.0.1", @@ -6485,7 +6468,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true + "optional": true }, "performance-now": { "version": "2.1.0", @@ -6528,6 +6511,16 @@ "resolved": "https://registry.npmjs.org/playwright/-/playwright-0.10.0.tgz", "integrity": "sha512-f3VRME/PIO5NbcWnlCDfXwPC0DAZJ7ETkcAdE+sensLCOkfDtLh97E71ZuxNCaPYsUA6FIPi5syD8pHJW/4hQQ==", "dev": true, + "optional": true, + "requires": { + "playwright-core": "=0.10.0" + } + }, + "playwright-chromium": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/playwright-chromium/-/playwright-chromium-0.10.0.tgz", + "integrity": "sha512-C9539clSFz2moxQpCM7G1YaThyDhnrUSdZAvysuoTXXFzuHVguNNHt5BnP5IczA91zkb51V0ESQCAdiydUzBoA==", + "optional": true, "requires": { "playwright-core": "=0.10.0" } @@ -6536,7 +6529,7 @@ "version": "0.10.0", "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-0.10.0.tgz", "integrity": "sha512-yernA6yrrBhmb8M5eO6GZsJOrBKWOZszlu65Luz8LP7ryaDExN1sE9XjQBNbiwJ5Gfs8cehtAO7GfTDJt+Z2cQ==", - "dev": true, + "optional": true, "requires": { "debug": "^4.1.0", "extract-zip": "^1.6.6", @@ -6555,7 +6548,7 @@ "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dev": true, + "optional": true, "requires": { "glob": "^7.1.3" } @@ -6564,13 +6557,31 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", - "dev": true, + "optional": true, "requires": { "async-limiter": "~1.0.0" } } } }, + "playwright-firefox": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/playwright-firefox/-/playwright-firefox-0.10.0.tgz", + "integrity": "sha512-W62qDExGIvYkLIZ+xxRn7i2VJBPHrq9+qvMqWbAL2mg+LMADdlbAmC5M4kAyTiCw57Ou1BuGkHhdZaxX+Oe6xg==", + "optional": true, + "requires": { + "playwright-core": "=0.10.0" + } + }, + "playwright-webkit": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/playwright-webkit/-/playwright-webkit-0.10.0.tgz", + "integrity": "sha512-PLV5+97mh521x78HngNOUCrMr1FjCVPxO5wjYI0K943wSM7M+WBOxWLiyjOW0/yztFDRoU1odk3jcB1l5d5JOA==", + "optional": true, + "requires": { + "playwright-core": "=0.10.0" + } + }, "please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", @@ -6590,7 +6601,7 @@ "version": "3.4.0", "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz", "integrity": "sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==", - "dev": true + "optional": true }, "posix-character-classes": { "version": "0.1.1", @@ -6641,13 +6652,12 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true + "optional": true }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" }, "prompts": { "version": "2.3.0", @@ -6663,7 +6673,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", - "dev": true + "optional": true }, "psl": { "version": "1.7.0", @@ -6775,7 +6785,7 @@ "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, + "optional": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -7193,8 +7203,7 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "safe-regex": { "version": "1.1.0", @@ -7825,7 +7834,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, + "optional": true, "requires": { "safe-buffer": "~5.1.0" } @@ -8124,7 +8133,7 @@ "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true + "optional": true }, "typedarray-to-buffer": { "version": "3.1.5", @@ -8247,7 +8256,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "optional": true }, "util.promisify": { "version": "1.0.1", @@ -8264,8 +8273,7 @@ "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" }, "v8-compile-cache": { "version": "2.1.0", @@ -8415,8 +8423,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "write": { "version": "1.0.3", @@ -8505,7 +8512,7 @@ "version": "2.4.1", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", - "dev": true, + "optional": true, "requires": { "fd-slicer": "~1.0.1" } diff --git a/package.json b/package.json index 8d419510..57b1896e 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,9 @@ "bugs": { "url": "https://github.com/mmarkelov/jest-playwright/issues" }, + "bin": { + "jest-playwright": "./lib/bin/index.js" + }, "repository": { "url": "https://github.com/mmarkelov/jest-playwright.git", "type": "git" @@ -21,7 +24,7 @@ "homepage": "https://github.com/mmarkelov/jest-playwright#readme", "scripts": { "build": "rm -rf lib/ && babel src -d lib --ignore '**/*.test.js'", - "format": "prettier --write \"*.{js,md}\" \"src/*.js\"", + "format": "prettier --write \"*.{js,md}\" \"src/**/*.js\"", "lint": "eslint .", "prepublishOnly": "yarn run build", "test:utils": "jest src/utils.test.js", diff --git a/src/bin/index.js b/src/bin/index.js new file mode 100644 index 00000000..70736464 --- /dev/null +++ b/src/bin/index.js @@ -0,0 +1,13 @@ +#!/usr/bin/env node + +import runner from './testProcess' + +const [, , ...args] = process.argv + +const run = async params => { + const sequence = params.find(param => param.startsWith('--')) + const jestParams = params.filter(param => param !== sequence) + await runner(sequence, jestParams) +} + +run(args) diff --git a/src/bin/testProcess.js b/src/bin/testProcess.js new file mode 100644 index 00000000..8031b7ea --- /dev/null +++ b/src/bin/testProcess.js @@ -0,0 +1,31 @@ +import { spawn, spawnSync } from 'child_process' +import { readConfig } from '../utils' +import { checkBrowsers } from './utils' +import { PARALLEL } from '../constants' + +const getSpawnOptions = browser => ({ + stdio: 'inherit', + shell: true, + env: { + ...process.env, + BROWSER: browser, + }, +}) + +const exec = ({ sequence, browser, params }) => { + // TODO Add messages for browser process + const options = getSpawnOptions(browser) + if (sequence === PARALLEL) { + spawn('node', [`node_modules/.bin/jest ${params}`], options) + } else { + spawnSync('node', [`node_modules/.bin/jest ${params}`], options) + } +} + +const runner = async (sequence, params) => { + const { browsers } = await readConfig() + checkBrowsers(browsers) + browsers.forEach(browser => exec({ sequence, browser, params })) +} + +export default runner diff --git a/src/bin/utils.js b/src/bin/utils.js new file mode 100644 index 00000000..14464e71 --- /dev/null +++ b/src/bin/utils.js @@ -0,0 +1,11 @@ +import { checkBrowserEnv } from '../utils' + +/* eslint import/prefer-default-export:0 */ +export function checkBrowsers(browsers) { + if (!browsers || !browsers.length) { + throw new Error( + 'You should define browsers with your jest-playwright.config.js', + ) + } + browsers.forEach(checkBrowserEnv) +} diff --git a/src/constants.js b/src/constants.js index 64b06a2d..cebe2bc7 100644 --- a/src/constants.js +++ b/src/constants.js @@ -2,6 +2,8 @@ export const CHROMIUM = 'chromium' export const FIREFOX = 'firefox' export const WEBKIT = 'webkit' +export const PARALLEL = '--parallel' + export const DEFAULT_CONFIG = { launchBrowserApp: { webSocket: true }, context: {}, diff --git a/src/parallel.js b/src/parallel.js deleted file mode 100644 index 26a73c05..00000000 --- a/src/parallel.js +++ /dev/null @@ -1,16 +0,0 @@ -import { spawn } from 'child_process' - -const exec = (browser = 'chromium') => { - spawn('node', ['node_modules/.bin/jest'], { - stdio: 'inherit', - shell: true, - env: { - ...process.env, - BROWSER: browser, - }, - }) -} - -exec() -exec('firefox') -exec('webkit') From 76745ad9408cb750da929b54e9f524555fb9a8e8 Mon Sep 17 00:00:00 2001 From: mmarkelov Date: Wed, 12 Feb 2020 12:03:25 +0300 Subject: [PATCH 3/3] Add info about new unstable features --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index d1dc32c7..c775a7b5 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,26 @@ Debugging tests can be hard sometimes and it is very useful to be able to pause await jestPlaywright.debug() ``` +## Unstable and experimental API + +From version **0.0.7** you can run you tests for multiple browsers. + +- You must have installed **playwright** package +- You must define browser to test with your `jest-playwright.config.js`: + +```javascript +module.exports = { + browsers: ["chromium", "webkit"], + ... +} +``` + +- You must run your tests with **jest-playwright** + +```json +"test:parallel": "jest-playwright --parallel" +``` + ## Inspiration Thanks to [Smooth Code](https://github.com/smooth-code) for great [jest-puppeteer](https://github.com/smooth-code/jest-puppeteer).