From 2a55c6dc0d8a99b0cb738288a91f04c6962027aa Mon Sep 17 00:00:00 2001 From: Eduardo Pereira Date: Tue, 24 Sep 2019 21:41:21 -0300 Subject: [PATCH 1/4] Headless test with puppeteer --- e2e_tests.sh | 6 +- package.json | 7 +- scripts/puppeteer-run.js | 23 +++++ webpack.unit.tests.config.js | 14 +-- yarn.lock | 160 +++++++++++++++++++++++++++++++++-- 5 files changed, 187 insertions(+), 23 deletions(-) create mode 100644 scripts/puppeteer-run.js diff --git a/e2e_tests.sh b/e2e_tests.sh index 1070fe1f..a29e1624 100755 --- a/e2e_tests.sh +++ b/e2e_tests.sh @@ -76,10 +76,10 @@ stop_chains() { } run_tests() { - yarn test:node + #yarn test:node # Disabled temporarily because it dies for some unknown reason on Travis - #yarn test:browser - yarn e2e:node + yarn test:browser + #yarn e2e:node } cleanup() { diff --git a/package.json b/package.json index cf05d437..9c902e47 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,13 @@ "format": "prettier --write \"src/**/*.ts\"", "test": "yarn test:node && yarn test:browser", "test:node": "yarn proto && yarn abi && tsc && tape dist/tests/unit_tests.js | tap-spec", - "test:browser": "yarn proto && yarn abi && tsc && webpack --config webpack.unit.tests.config.js | tap-spec", + "test:browser": "yarn proto && yarn abi && tsc && webpack --config webpack.unit.tests.config.js | yarn puppeteer-run ./dist/browser_unit_tests.js | tap-spec", "test:e2e:local": "bash e2e_tests.sh", "e2e:node": "yarn proto && yarn abi && tsc && tape -r dotenv/config dotenv_config_path=./.env.test dist/tests/e2e_tests.js | tap-spec", "e2e:browser": "yarn proto && yarn abi && tsc && webpack --config webpack.e2e.test.config.js | tap-spec", "proto": "node ./scripts/gen-proto.js", "abi": "node ./scripts/abi.js && bash ./scripts/fix_types.sh", + "puppeteer-run": "node ./scripts/puppeteer-run.js", "copy-contracts": "node ./scripts/copy-contracts.js", "prepublish": "yarn proto && yarn abi && yarn build && webpack" }, @@ -39,7 +40,9 @@ "ethereumjs-util": "^5.2.0", "ethers": "^4.0.9", "google-protobuf": "3.6", + "karma-phantomjs-launcher": "^1.0.4", "lodash": "^4.17.11", + "phantomjs-prebuilt": "^2.1.16", "retry": "^0.12.0", "ripemd160": "^2.0.1", "rlp": "^2.1.0", @@ -73,6 +76,8 @@ "shelljs": "^0.8.2", "tap-spec": "^5.0.0", "tape": "4.9", + "tape-puppet": "git+https://git@github.com/eduardonunesp/tape-puppet.git#9c1ed208391957de40e90962e89730417be1a30e", + "ts-protoc-gen": "^", "ts-protoc-gen": "^0.6.0", "tslint": "^5.9.1", "tslint-config-prettier": "^1.12.0", diff --git a/scripts/puppeteer-run.js b/scripts/puppeteer-run.js new file mode 100644 index 00000000..5421341c --- /dev/null +++ b/scripts/puppeteer-run.js @@ -0,0 +1,23 @@ +const { readFileSync } = require('fs') +const puppeteer = require('puppeteer') + +const file = readFileSync(process.argv[2], 'utf-8') + +const html = ` + + + +` +;(async () => { + const browser = await puppeteer.launch() + const page = await browser.newPage() + page.setContent(html) + + page.on('console', msg => console.log(msg.text())) + + await page.waitFor(2000) + + await browser.close() +})() diff --git a/webpack.unit.tests.config.js b/webpack.unit.tests.config.js index 343b92f8..a9176b99 100644 --- a/webpack.unit.tests.config.js +++ b/webpack.unit.tests.config.js @@ -1,7 +1,6 @@ // This config is used to run tests in the browser. -const path = require('path'); -const WebpackTapeRun = require('webpack-tape-run'); +const path = require('path') module.exports = { mode: 'production', @@ -19,10 +18,10 @@ module.exports = { crypto: true, util: true, stream: true, - path: 'empty', + path: 'empty' }, externals: { - shelljs: 'commonjs shelljs', + shelljs: 'commonjs shelljs' }, module: { rules: [ @@ -33,14 +32,9 @@ module.exports = { } ] }, - plugins: [ - // Be default tests will run in Electron, but can use other browsers too, - // see https://github.com/syarul/webpack-tape-run for plugin settings. - new WebpackTapeRun() - ], // silence irrelevant messages performance: { hints: false }, stats: 'errors-only' -}; +} diff --git a/yarn.lock b/yarn.lock index 87d345ba..fcc27639 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1074,6 +1074,13 @@ aes-js@3.0.0: resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" integrity sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0= +agent-base@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" + integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== + dependencies: + es6-promisify "^5.0.0" + ajv-errors@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d" @@ -2841,11 +2848,23 @@ es6-iterator@~2.0.3: es5-ext "^0.10.35" es6-symbol "^3.1.1" +es6-promise@^4.0.3: + version "4.2.8" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" + integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== + es6-promise@^4.0.5: version "4.2.6" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.6.tgz#b685edd8258886365ea62b57d30de28fadcd974f" integrity sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q== +es6-promisify@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" + integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= + dependencies: + es6-promise "^4.0.3" + es6-symbol@^3.1.1, es6-symbol@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" @@ -3196,7 +3215,7 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -extract-zip@^1.0.3: +extract-zip@^1.0.3, extract-zip@^1.6.5, extract-zip@^1.6.6: version "1.6.7" resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9" integrity sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k= @@ -3457,6 +3476,15 @@ fs-extra@^0.30.0: path-is-absolute "^1.0.0" rimraf "^2.2.8" +fs-extra@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" + integrity sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA= + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + klaw "^1.0.0" + fs-extra@^4.0.2: version "4.0.3" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" @@ -3831,6 +3859,14 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.1" +hasha@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1" + integrity sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE= + dependencies: + is-stream "^1.0.1" + pinkie-promise "^2.0.0" + he@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" @@ -3940,6 +3976,14 @@ https-browserify@^1.0.0: resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= +https-proxy-agent@^2.2.1: + version "2.2.2" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz#271ea8e90f836ac9f119daccd39c19ff7dfb0793" + integrity sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg== + dependencies: + agent-base "^4.3.0" + debug "^3.1.0" + iconv-lite@0.4.23: version "0.4.23" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63" @@ -4293,7 +4337,7 @@ is-retry-allowed@^1.0.0: resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" integrity sha1-EaBgVotnM5REAz0BJaYaINVk+zQ= -is-stream@^1.0.0, is-stream@^1.1.0: +is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= @@ -4486,6 +4530,14 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" +karma-phantomjs-launcher@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz#d23ca34801bda9863ad318e3bb4bd4062b13acd2" + integrity sha1-0jyjSAG9qYY60xjju0vUBisTrNI= + dependencies: + lodash "^4.0.1" + phantomjs-prebuilt "^2.1.7" + keccak@^1.0.2: version "1.4.0" resolved "https://registry.yarnpkg.com/keccak/-/keccak-1.4.0.tgz#572f8a6dbee8e7b3aa421550f9e6408ca2186f80" @@ -4504,6 +4556,11 @@ keccakjs@^0.2.1: browserify-sha3 "^0.0.4" sha3 "^1.2.2" +kew@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b" + integrity sha1-edk9LTM2PW/dKXCzNdkUGtWR15s= + keypather@^1.10.2: version "1.10.2" resolved "https://registry.yarnpkg.com/keypather/-/keypather-1.10.2.tgz#e0449632d4b3e516f21cc014ce7c5644fddce614" @@ -4604,16 +4661,16 @@ locate-path@^3.0.0: p-locate "^3.0.0" path-exists "^3.0.0" +lodash@^4.0.1, lodash@^4.17.15: + version "4.17.15" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" + integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== -lodash@^4.17.15: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== - loose-envify@^1.0.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" @@ -4827,6 +4884,11 @@ mime@^1.2.11, mime@^1.6.0: resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== +mime@^2.0.3: + version "2.4.4" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.4.tgz#bd7b91135fc6b01cde3e9bae33d659b63d8857e5" + integrity sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA== + mimic-fn@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" @@ -5582,6 +5644,21 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= +phantomjs-prebuilt@^2.1.16, phantomjs-prebuilt@^2.1.7: + version "2.1.16" + resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef" + integrity sha1-79ISpKOWbTZHaE6ouniFSb4q7+8= + dependencies: + es6-promise "^4.0.3" + extract-zip "^1.6.5" + fs-extra "^1.0.0" + hasha "^2.2.0" + kew "^0.7.0" + progress "^1.1.8" + request "^2.81.0" + request-progress "^2.0.1" + which "^1.2.10" + phantomjs-stream@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/phantomjs-stream/-/phantomjs-stream-1.1.1.tgz#5650f42028c09e846bc463b82bf4cafc43a3ba2b" @@ -5732,6 +5809,16 @@ progress-stream@^1.1.0: speedometer "~0.1.2" through2 "~0.2.3" +progress@^1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" + integrity sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74= + +progress@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" + integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== + promise-inflight@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" @@ -5753,6 +5840,11 @@ proxy-addr@~2.0.4: forwarded "~0.1.2" ipaddr.js "1.8.0" +proxy-from-env@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" + integrity sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4= + prr@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" @@ -5833,6 +5925,20 @@ punycode@^2.1.0: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== +puppeteer@^1.7.0: + version "1.20.0" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.20.0.tgz#e3d267786f74e1d87cf2d15acc59177f471bbe38" + integrity sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ== + dependencies: + debug "^4.1.0" + extract-zip "^1.6.6" + https-proxy-agent "^2.2.1" + mime "^2.0.3" + progress "^2.0.1" + proxy-from-env "^1.0.0" + rimraf "^2.6.1" + ws "^6.1.0" + qs@6.5.2, qs@~6.5.2: version "6.5.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" @@ -6115,7 +6221,14 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -request@^2.45.0, request@^2.79.0: +request-progress@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/request-progress/-/request-progress-2.0.1.tgz#5d36bb57961c673aa5b788dbc8141fdf23b44e08" + integrity sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg= + dependencies: + throttleit "^1.0.0" + +request@^2.45.0, request@^2.79.0, request@^2.81.0: version "2.88.0" resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg== @@ -6925,6 +7038,14 @@ swarm-js@0.1.39: tar "^4.0.2" xhr-request-promise "^0.1.2" +tap-finished@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/tap-finished/-/tap-finished-0.0.1.tgz#08b5b543fdc04830290c6c561279552e71c4bd67" + integrity sha1-CLW1Q/3ASDApDGxWEnlVLnHEvWc= + dependencies: + tap-parser "~0.2.0" + through "~2.3.4" + tap-out@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tap-out/-/tap-out-2.1.0.tgz#c093079a915036de8b835bfa3297f14458b15358" @@ -6961,6 +7082,15 @@ tapable@^1.0.0, tapable@^1.1.0: resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.1.tgz#4d297923c5a72a42360de2ab52dadfaaec00018e" integrity sha512-9I2ydhj8Z9veORCw5PRm4u9uebCn0mcCa6scWoNcbZ6dAtoo2618u9UUzxgmsCOreJpqDDuv61LvwofW7hLcBA== +"tape-puppet@git+https://git@github.com/eduardonunesp/tape-puppet.git#9c1ed208391957de40e90962e89730417be1a30e": + version "0.1.7" + resolved "git+https://git@github.com/eduardonunesp/tape-puppet.git#9c1ed208391957de40e90962e89730417be1a30e" + dependencies: + minimist "^1.2.0" + pump "^3.0.0" + puppeteer "^1.7.0" + tap-finished "0.0.1" + tape-run@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/tape-run/-/tape-run-3.0.4.tgz#7f68be0c494ccc8736a9c98636badb204e6590d1" @@ -7090,6 +7220,11 @@ throttleit@0.0.2: resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-0.0.2.tgz#cfedf88e60c00dd9697b61fdd2a8343a9b680eaf" integrity sha1-z+34jmDADdlpe2H90qg0OptoDq8= +throttleit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c" + integrity sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw= + through2@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/through2/-/through2-1.1.1.tgz#0847cbc4449f3405574dbdccd9bb841b83ac3545" @@ -8069,7 +8204,7 @@ which-pm-runs@^1.0.0: resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb" integrity sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs= -which@^1.2.14, which@^1.2.9: +which@^1.2.10, which@^1.2.14, which@^1.2.9: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== @@ -8131,6 +8266,13 @@ ws@^5.2.2: dependencies: async-limiter "~1.0.0" +ws@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb" + integrity sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA== + dependencies: + async-limiter "~1.0.0" + xhr-request-promise@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/xhr-request-promise/-/xhr-request-promise-0.1.2.tgz#343c44d1ee7726b8648069682d0f840c83b4261d" From 903c1f2b4a474708af4a9f2b8299529a3ab43c0e Mon Sep 17 00:00:00 2001 From: Eduardo Pereira Date: Sun, 29 Sep 2019 13:21:06 -0300 Subject: [PATCH 2/4] Fix command chain --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9c902e47..5eb6944d 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "format": "prettier --write \"src/**/*.ts\"", "test": "yarn test:node && yarn test:browser", "test:node": "yarn proto && yarn abi && tsc && tape dist/tests/unit_tests.js | tap-spec", - "test:browser": "yarn proto && yarn abi && tsc && webpack --config webpack.unit.tests.config.js | yarn puppeteer-run ./dist/browser_unit_tests.js | tap-spec", + "test:browser": "yarn proto && yarn abi && tsc && webpack --config webpack.unit.tests.config.js && yarn puppeteer-run ./dist/browser_unit_tests.js | tap-spec", "test:e2e:local": "bash e2e_tests.sh", "e2e:node": "yarn proto && yarn abi && tsc && tape -r dotenv/config dotenv_config_path=./.env.test dist/tests/e2e_tests.js | tap-spec", "e2e:browser": "yarn proto && yarn abi && tsc && webpack --config webpack.e2e.test.config.js | tap-spec", From 644eb3d84f68ab4d20514491f97e48ab04eb6762 Mon Sep 17 00:00:00 2001 From: Eduardo Pereira Date: Sun, 29 Sep 2019 14:05:47 -0300 Subject: [PATCH 3/4] Cleanup --- e2e_tests.sh | 5 ++--- package.json | 9 +++----- .../{puppeteer-run.js => run-puppeteer.js} | 0 webpack.unit.tests.config.js | 1 + yarn.lock | 21 ++----------------- 5 files changed, 8 insertions(+), 28 deletions(-) rename scripts/{puppeteer-run.js => run-puppeteer.js} (100%) diff --git a/e2e_tests.sh b/e2e_tests.sh index a29e1624..f221b665 100755 --- a/e2e_tests.sh +++ b/e2e_tests.sh @@ -76,10 +76,9 @@ stop_chains() { } run_tests() { - #yarn test:node - # Disabled temporarily because it dies for some unknown reason on Travis + yarn test:node yarn test:browser - #yarn e2e:node + yarn e2e:node } cleanup() { diff --git a/package.json b/package.json index 5eb6944d..3dc112d8 100644 --- a/package.json +++ b/package.json @@ -19,13 +19,13 @@ "format": "prettier --write \"src/**/*.ts\"", "test": "yarn test:node && yarn test:browser", "test:node": "yarn proto && yarn abi && tsc && tape dist/tests/unit_tests.js | tap-spec", - "test:browser": "yarn proto && yarn abi && tsc && webpack --config webpack.unit.tests.config.js && yarn puppeteer-run ./dist/browser_unit_tests.js | tap-spec", + "test:browser": "yarn proto && yarn abi && tsc && webpack --config webpack.unit.tests.config.js && yarn run-puppeteer ./dist/browser_unit_tests.js | tap-spec", "test:e2e:local": "bash e2e_tests.sh", "e2e:node": "yarn proto && yarn abi && tsc && tape -r dotenv/config dotenv_config_path=./.env.test dist/tests/e2e_tests.js | tap-spec", "e2e:browser": "yarn proto && yarn abi && tsc && webpack --config webpack.e2e.test.config.js | tap-spec", "proto": "node ./scripts/gen-proto.js", "abi": "node ./scripts/abi.js && bash ./scripts/fix_types.sh", - "puppeteer-run": "node ./scripts/puppeteer-run.js", + "run-puppeteer": "node ./scripts/run-puppeteer.js", "copy-contracts": "node ./scripts/copy-contracts.js", "prepublish": "yarn proto && yarn abi && yarn build && webpack" }, @@ -40,9 +40,7 @@ "ethereumjs-util": "^5.2.0", "ethers": "^4.0.9", "google-protobuf": "3.6", - "karma-phantomjs-launcher": "^1.0.4", "lodash": "^4.17.11", - "phantomjs-prebuilt": "^2.1.16", "retry": "^0.12.0", "ripemd160": "^2.0.1", "rlp": "^2.1.0", @@ -73,11 +71,10 @@ "dotenv-webpack": "^1.5.5", "ganache-cli": "^6.1.8", "prettier": "1.12.1", + "puppeteer": "^1.20.0", "shelljs": "^0.8.2", "tap-spec": "^5.0.0", "tape": "4.9", - "tape-puppet": "git+https://git@github.com/eduardonunesp/tape-puppet.git#9c1ed208391957de40e90962e89730417be1a30e", - "ts-protoc-gen": "^", "ts-protoc-gen": "^0.6.0", "tslint": "^5.9.1", "tslint-config-prettier": "^1.12.0", diff --git a/scripts/puppeteer-run.js b/scripts/run-puppeteer.js similarity index 100% rename from scripts/puppeteer-run.js rename to scripts/run-puppeteer.js diff --git a/webpack.unit.tests.config.js b/webpack.unit.tests.config.js index a9176b99..dd7f0410 100644 --- a/webpack.unit.tests.config.js +++ b/webpack.unit.tests.config.js @@ -1,6 +1,7 @@ // This config is used to run tests in the browser. const path = require('path') +const exec = require('child_process').exec module.exports = { mode: 'production', diff --git a/yarn.lock b/yarn.lock index fcc27639..6f004267 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5644,7 +5644,7 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -phantomjs-prebuilt@^2.1.16, phantomjs-prebuilt@^2.1.7: +phantomjs-prebuilt@^2.1.7: version "2.1.16" resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef" integrity sha1-79ISpKOWbTZHaE6ouniFSb4q7+8= @@ -5925,7 +5925,7 @@ punycode@^2.1.0: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -puppeteer@^1.7.0: +puppeteer@^1.20.0: version "1.20.0" resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.20.0.tgz#e3d267786f74e1d87cf2d15acc59177f471bbe38" integrity sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ== @@ -7038,14 +7038,6 @@ swarm-js@0.1.39: tar "^4.0.2" xhr-request-promise "^0.1.2" -tap-finished@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/tap-finished/-/tap-finished-0.0.1.tgz#08b5b543fdc04830290c6c561279552e71c4bd67" - integrity sha1-CLW1Q/3ASDApDGxWEnlVLnHEvWc= - dependencies: - tap-parser "~0.2.0" - through "~2.3.4" - tap-out@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tap-out/-/tap-out-2.1.0.tgz#c093079a915036de8b835bfa3297f14458b15358" @@ -7082,15 +7074,6 @@ tapable@^1.0.0, tapable@^1.1.0: resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.1.tgz#4d297923c5a72a42360de2ab52dadfaaec00018e" integrity sha512-9I2ydhj8Z9veORCw5PRm4u9uebCn0mcCa6scWoNcbZ6dAtoo2618u9UUzxgmsCOreJpqDDuv61LvwofW7hLcBA== -"tape-puppet@git+https://git@github.com/eduardonunesp/tape-puppet.git#9c1ed208391957de40e90962e89730417be1a30e": - version "0.1.7" - resolved "git+https://git@github.com/eduardonunesp/tape-puppet.git#9c1ed208391957de40e90962e89730417be1a30e" - dependencies: - minimist "^1.2.0" - pump "^3.0.0" - puppeteer "^1.7.0" - tap-finished "0.0.1" - tape-run@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/tape-run/-/tape-run-3.0.4.tgz#7f68be0c494ccc8736a9c98636badb204e6590d1" From d75126a82d56e90ed28577acf8abcbcfbbf46898 Mon Sep 17 00:00:00 2001 From: Eduardo Pereira Date: Sun, 29 Sep 2019 14:29:39 -0300 Subject: [PATCH 4/4] Improve tests --- scripts/run-puppeteer.js | 7 ++++--- webpack.unit.tests.config.js | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/run-puppeteer.js b/scripts/run-puppeteer.js index 5421341c..4d229750 100644 --- a/scripts/run-puppeteer.js +++ b/scripts/run-puppeteer.js @@ -6,7 +6,9 @@ const file = readFileSync(process.argv[2], 'utf-8') const html = ` ` @@ -14,10 +16,9 @@ const html = ` const browser = await puppeteer.launch() const page = await browser.newPage() page.setContent(html) - page.on('console', msg => console.log(msg.text())) + // TODO: Should improve to wait for the test really ends await page.waitFor(2000) - await browser.close() })() diff --git a/webpack.unit.tests.config.js b/webpack.unit.tests.config.js index dd7f0410..f764c581 100644 --- a/webpack.unit.tests.config.js +++ b/webpack.unit.tests.config.js @@ -1,7 +1,5 @@ // This config is used to run tests in the browser. - const path = require('path') -const exec = require('child_process').exec module.exports = { mode: 'production', @@ -11,7 +9,6 @@ module.exports = { filename: 'browser_unit_tests.js', libraryTarget: 'umd', globalObject: 'this', - // libraryExport: 'default', library: 'loom_unit_tests' }, node: {