From 1f113e1205dbb7748b3bf1e24c3eb9be2e28e8c8 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Tue, 23 Jan 2018 10:42:26 +0900 Subject: [PATCH 01/17] End the app if an error occurs --- tests/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/index.js b/tests/index.js index b0a23b62..90ae4783 100644 --- a/tests/index.js +++ b/tests/index.js @@ -27,6 +27,7 @@ tap('init', function (t) { .then((val) => t.notEqual(val.width, 0, 'getBounds')) .then(() => app.browserWindow.getBounds()) .then((val) => t.notEqual(val.height, 0, 'getBounds')) + .catch(e => t.fail(e)) .then(() => endTest(app)) }) t.end() @@ -53,6 +54,7 @@ tap('onboarding', function (t) { .then(() => app.client.click('button')) .then(() => wait()) .then(() => app.client.getText('button[title="Skip Intro"]')) + .catch(e => t.fail(e)) .then(() => endTest(app)) }) t.end() @@ -99,6 +101,7 @@ tap('working with dats', function (t) { .then(() => wait()) .then(() => app.client.getText('.tutorial')) .then((text) => t.ok(text.toLowerCase().match(/share/), 'now the dat is gone and welcome screen is back')) + .catch(e => t.fail(e)) .then(() => endTest(app)) }) From f791eb155d1629f5d85a2b92d9f8fba696171e2c Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Wed, 24 Jan 2018 11:10:33 +0900 Subject: [PATCH 02/17] Made tests cancelable through Ctrl+C --- tests/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/index.js b/tests/index.js index 90ae4783..8b87ae1e 100644 --- a/tests/index.js +++ b/tests/index.js @@ -107,11 +107,13 @@ tap('working with dats', function (t) { // Create a new app instance function createApp () { - return new spectron.Application({ + var app = new spectron.Application({ path: path.join(__dirname, '../node_modules/.bin/electron'), args: [path.join(__dirname, '../index.js'), '--data', TEST_DATA, '--db', TEST_DATA_DB], env: { NODE_ENV: 'test', RUNNING_IN_SPECTRON: true } }) + process.on('SIGTERM', () => endTest(app)) + return app } // Starts the app, waits for it to load, returns a promise From 95b4639267af7627395e660f26e1f02ef312bee4 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Tue, 23 Jan 2018 13:31:10 +0900 Subject: [PATCH 03/17] Fixing a proper reset of the tests folder --- tests/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/index.js b/tests/index.js index 8b87ae1e..e7d4b388 100644 --- a/tests/index.js +++ b/tests/index.js @@ -3,6 +3,7 @@ var spectron = require('spectron') var path = require('path') var tap = require('tap').test var del = require('del') +var { execSync } = require('child_process') var TEST_DATA = path.join(__dirname, 'test_data') var TEST_DATA_DB = path.join(TEST_DATA, 'multidat.json') @@ -138,7 +139,13 @@ function wait (ms) { // Quit the app, end the test, either in success (!err) or failure (err) function endTest (app) { - var paths = [TEST_DATA, path.join(__dirname, 'fixtures', '.dat')] - return del(paths) - .then(() => app.stop()) + var fixPath = path.join(__dirname, 'fixtures') + return Promise.all([ + del(fixPath), + del(TEST_DATA) + ]) + .then(() => { + execSync(`git checkout -- "${fixPath}"`) + return app.stop() + }) } From ef5acdcd654333fd58b07666f2b578996f61214c Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Wed, 24 Jan 2018 11:21:31 +0900 Subject: [PATCH 04/17] Updated tap dependency --- package-lock.json | 122 ++++++++++++++++++++++++++++++++++------------ package.json | 2 +- 2 files changed, 93 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 691d90a9..721b0c6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,9 +10,18 @@ "integrity": "sha512-+rr4OgeTNrLuJAf09o3USdttEYiXvZshWMkhD6wR9v1ieXH0JM1Q2yT41/cJuJcqiPpSXlM/g3aR+Y5MWQdr0Q==", "dev": true, "requires": { - "7zip-bin-mac": "1.0.1" + "7zip-bin-linux": "1.3.1", + "7zip-bin-mac": "1.0.1", + "7zip-bin-win": "2.1.1" } }, + "7zip-bin-linux": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/7zip-bin-linux/-/7zip-bin-linux-1.3.1.tgz", + "integrity": "sha512-Wv1uEEeHbTiS1+ycpwUxYNuIcyohU6Y6vEqY3NquBkeqy0YhVdsNUGsj0XKSRciHR6LoJSEUuqYUexmws3zH7Q==", + "dev": true, + "optional": true + }, "7zip-bin-mac": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/7zip-bin-mac/-/7zip-bin-mac-1.0.1.tgz", @@ -20,6 +29,13 @@ "dev": true, "optional": true }, + "7zip-bin-win": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/7zip-bin-win/-/7zip-bin-win-2.1.1.tgz", + "integrity": "sha512-6VGEW7PXGroTsoI2QW3b0ea95HJmbVBHvfANKLLMzSzFA1zKqVX5ybNuhmeGpf6vA0x8FJTt6twpprDANsY5WQ==", + "dev": true, + "optional": true + }, "@types/node": { "version": "7.0.48", "resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.48.tgz", @@ -1376,9 +1392,9 @@ "dev": true }, "commander": { - "version": "2.12.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", - "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", + "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", "dev": true }, "cryptiles": { @@ -1414,7 +1430,7 @@ "dev": true, "requires": { "chalk": "1.1.3", - "commander": "2.12.2", + "commander": "2.13.0", "is-my-json-valid": "2.16.1", "pinkie-promise": "2.0.1" } @@ -5857,6 +5873,23 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, + "minipass": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz", + "integrity": "sha512-u1aUllxPJUI07cOqzR7reGmQxmCqlH88uIIsf6XZFEWgw7gXKpJdR+5R9Y3KEDmWYkdIz9wXZs3C0jOPxejk/Q==", + "dev": true, + "requires": { + "yallist": "3.0.2" + }, + "dependencies": { + "yallist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", + "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", + "dev": true + } + } + }, "mirror-folder": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/mirror-folder/-/mirror-folder-2.1.1.tgz", @@ -6456,15 +6489,15 @@ "dev": true }, "nyc": { - "version": "11.3.0", - "resolved": "https://registry.npmjs.org/nyc/-/nyc-11.3.0.tgz", - "integrity": "sha512-oUu0WHt1k/JMIODvAYXX6C50Mupw2GO34P/Jdg2ty9xrLufBthHiKR2gf08aF+9S0abW1fl24R7iKRBXzibZmg==", + "version": "11.4.1", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-11.4.1.tgz", + "integrity": "sha512-5eCZpvaksFVjP2rt1r60cfXmt3MUtsQDw8bAzNqNEr4WLvUMLgiVENMf/B9bE9YAX0mGVvaGA3v9IS9ekNqB1Q==", "dev": true, "requires": { "archy": "1.0.0", "arrify": "1.0.1", "caching-transform": "1.0.1", - "convert-source-map": "1.5.0", + "convert-source-map": "1.5.1", "debug-log": "1.0.1", "default-require-extensions": "1.0.0", "find-cache-dir": "0.1.1", @@ -6484,7 +6517,7 @@ "resolve-from": "2.0.0", "rimraf": "2.6.2", "signal-exit": "3.0.2", - "spawn-wrap": "1.3.8", + "spawn-wrap": "1.4.2", "test-exclude": "4.1.1", "yargs": "10.0.3", "yargs-parser": "8.0.0" @@ -6594,8 +6627,8 @@ "bundled": true, "dev": true, "requires": { - "core-js": "2.5.1", - "regenerator-runtime": "0.11.0" + "core-js": "2.5.3", + "regenerator-runtime": "0.11.1" } }, "babel-template": { @@ -6744,12 +6777,12 @@ "dev": true }, "convert-source-map": { - "version": "1.5.0", + "version": "1.5.1", "bundled": true, "dev": true }, "core-js": { - "version": "2.5.1", + "version": "2.5.3", "bundled": true, "dev": true }, @@ -7053,7 +7086,7 @@ "dev": true }, "is-buffer": { - "version": "1.1.5", + "version": "1.1.6", "bundled": true, "dev": true }, @@ -7251,7 +7284,7 @@ "bundled": true, "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } }, "lazy-cache": { @@ -7620,7 +7653,7 @@ "bundled": true, "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } } } @@ -7630,7 +7663,7 @@ "bundled": true, "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } } } @@ -7666,7 +7699,7 @@ } }, "regenerator-runtime": { - "version": "0.11.0", + "version": "0.11.1", "bundled": true, "dev": true }, @@ -7772,7 +7805,7 @@ "dev": true }, "spawn-wrap": { - "version": "1.3.8", + "version": "1.4.2", "bundled": true, "dev": true, "requires": { @@ -10074,9 +10107,9 @@ "integrity": "sha512-bq40Dxl0Q9LFcFsoU4BmTlR4Y9Ta/9AClAhmKhBBdXN0isup9dXtYmFIJGYHz2EOVOf/gO/FONEH0BDa/iNYkg==" }, "tap": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/tap/-/tap-10.7.3.tgz", - "integrity": "sha512-oS/FIq+tcmxVgYn5usKtLsX+sOHNEj+G7JIQE9SBjO5mVYB1rbaEJJiDbnYp8k0ZqY2Pe4HbYEpkvzm9jfLDyw==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/tap/-/tap-11.0.1.tgz", + "integrity": "sha512-YfrPp7FFxASC4tK4DEAKnnTxyg+J7T8kh8NiOmICNhiGvSojPAV34Ir4DDElFvnIiDEMzDP7233lw3WacFvIFQ==", "dev": true, "requires": { "bind-obj-methods": "1.0.0", @@ -10090,21 +10123,37 @@ "glob": "7.1.2", "isexe": "2.0.0", "js-yaml": "3.10.0", - "nyc": "11.3.0", + "minipass": "2.2.1", + "mkdirp": "0.5.1", + "nyc": "11.4.1", "opener": "1.4.3", "os-homedir": "1.0.2", "own-or": "1.0.0", "own-or-env": "1.0.0", - "readable-stream": "2.3.3", + "rimraf": "2.6.2", "signal-exit": "3.0.2", "source-map-support": "0.4.18", "stack-utils": "1.0.1", "tap-mocha-reporter": "3.0.6", - "tap-parser": "5.4.0", + "tap-parser": "7.0.0", "tmatch": "3.1.0", "trivial-deferred": "1.0.1", "tsame": "1.1.2", + "write-file-atomic": "2.3.0", "yapool": "1.0.0" + }, + "dependencies": { + "write-file-atomic": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", + "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "imurmurhash": "0.1.4", + "signal-exit": "3.0.2" + } + } } }, "tap-mocha-reporter": { @@ -10122,6 +10171,19 @@ "readable-stream": "2.3.3", "tap-parser": "5.4.0", "unicode-length": "1.0.3" + }, + "dependencies": { + "tap-parser": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-5.4.0.tgz", + "integrity": "sha512-BIsIaGqv7uTQgTW1KLTMNPSEQf4zDDPgYOBRdgOfuB+JFOLRBfEu6cLa/KvMvmqggu1FKXDfitjLwsq4827RvA==", + "dev": true, + "requires": { + "events-to-array": "1.1.2", + "js-yaml": "3.10.0", + "readable-stream": "2.3.3" + } + } } }, "tap-out": { @@ -10148,14 +10210,14 @@ } }, "tap-parser": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-5.4.0.tgz", - "integrity": "sha512-BIsIaGqv7uTQgTW1KLTMNPSEQf4zDDPgYOBRdgOfuB+JFOLRBfEu6cLa/KvMvmqggu1FKXDfitjLwsq4827RvA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-7.0.0.tgz", + "integrity": "sha512-05G8/LrzqOOFvZhhAk32wsGiPZ1lfUrl+iV7+OkKgfofZxiceZWMHkKmow71YsyVQ8IvGBP2EjcIjE5gL4l5lA==", "dev": true, "requires": { "events-to-array": "1.1.2", "js-yaml": "3.10.0", - "readable-stream": "2.3.3" + "minipass": "2.2.1" } }, "tap-spec": { diff --git a/package.json b/package.json index 51fbb205..7fd86f21 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "spectron": "^3.5.0", "spok": "^0.7.0", "standard": "^7.1.2", - "tap": "^10.3.2", + "tap": "^11.0.1", "tap-spec": "^4.1.1", "tape": "^4.6.3", "through2": "^2.0.3", From 51289a6542f1fe6060a324e88180f201fe14a2cb Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Fri, 26 Jan 2018 00:32:26 +0900 Subject: [PATCH 05/17] Using shebang to make sure the correct executable is called. --- package.json | 2 +- tests/dat-manager.js | 1 + tests/intro.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 tests/dat-manager.js mode change 100644 => 100755 tests/intro.js diff --git a/package.json b/package.json index 7fd86f21..13c506ba 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "start": "cross-env NODE_ENV=development electron .", "test": "standard && npm run deps && npm run test:unit && npm run test:integration", "test:integration": "node tests", - "test:unit": "node tests/intro.js && electron tests/dat-manager.js", + "test:unit": "./tests/dat-manager.js && ./tests/intro.js", "postinstall": "node scripts/build.js postinstall", "pack": "build --dir", "dist": "build --publish=onTagOrDraft" diff --git a/tests/dat-manager.js b/tests/dat-manager.js old mode 100644 new mode 100755 index a867da32..a57dad55 --- a/tests/dat-manager.js +++ b/tests/dat-manager.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node node_modules/.bin/electron var tape = require('tape') var Multidat = require('multidat') var toilet = require('toiletdb/inmemory') diff --git a/tests/intro.js b/tests/intro.js old mode 100644 new mode 100755 index f256219b..f0126517 --- a/tests/intro.js +++ b/tests/intro.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node var EventEmitter = require('events').EventEmitter var tape = require('tape') var spok = require('spok') From a7d8315bf79ea9f9ff8f54368eb5e43971fc16cc Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Fri, 26 Jan 2018 00:34:04 +0900 Subject: [PATCH 06/17] Used shebang for tests/index --- package.json | 2 +- tests/index.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 tests/index.js diff --git a/package.json b/package.json index 13c506ba..dbd0148a 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "build-background": "node scripts/build.js background", "start": "cross-env NODE_ENV=development electron .", "test": "standard && npm run deps && npm run test:unit && npm run test:integration", - "test:integration": "node tests", + "test:integration": "./tests/index.js", "test:unit": "./tests/dat-manager.js && ./tests/intro.js", "postinstall": "node scripts/build.js postinstall", "pack": "build --dir", diff --git a/tests/index.js b/tests/index.js old mode 100644 new mode 100755 index e7d4b388..03f0efb0 --- a/tests/index.js +++ b/tests/index.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node var clipboard = require('clipboardy') var spectron = require('spectron') var path = require('path') From 5f8c42027b25e1949572005d8a462fccdf60eca9 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Thu, 25 Jan 2018 12:19:51 +0900 Subject: [PATCH 07/17] Proper tape tests need to be ended. --- tests/dat-manager.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/dat-manager.js b/tests/dat-manager.js index a57dad55..057f12ed 100755 --- a/tests/dat-manager.js +++ b/tests/dat-manager.js @@ -73,6 +73,7 @@ tape('dat-manager', function (t) { }) } }) + t.end() }) t.test('.create(dir, opts, cb)', function (t) { @@ -119,6 +120,7 @@ tape('dat-manager', function (t) { }) }) }) + t.end() }) t.test('.close(key, cb)', function (t) { @@ -148,6 +150,7 @@ tape('dat-manager', function (t) { }) }) }) + t.end() }) t.test('.pause(dat, cb)', function (t) { @@ -174,6 +177,7 @@ tape('dat-manager', function (t) { }) }) }) + t.end() }) t.test('.resume(dat, cb)', function (t) { @@ -206,6 +210,7 @@ tape('dat-manager', function (t) { }) }) }) + t.end() }) t.test('.togglePause(dat, cb)', function (t) { @@ -268,4 +273,6 @@ tape('dat-manager', function (t) { t.end() process.exit(Number(!t._ok)) }) + + t.end() }) From 801b8bc8fe79e42c191a111aecdc94b20147b3d2 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Thu, 25 Jan 2018 23:07:37 +0900 Subject: [PATCH 08/17] Making use of resolveMatch for shorter, better readable tests --- tests/index.js | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/tests/index.js b/tests/index.js index 03f0efb0..3012dc47 100755 --- a/tests/index.js +++ b/tests/index.js @@ -13,22 +13,16 @@ tap('init', function (t) { t.test('should be able to boot up the app', function (t) { var app = createApp() return waitForLoad(app) - .then(() => app.browserWindow.isVisible()) - .then((val) => t.ok(val, 'isVisible')) - .then(() => app.client.getWindowCount()) - .then((val) => t.equal(val, 1, 'getWindowCount')) - .then(() => app.browserWindow.isMinimized()) - .then((val) => t.equal(val, false, 'isMinimized')) - .then(() => app.browserWindow.isDevToolsOpened()) - .then((val) => t.equal(val, false, 'isDevToolsOpened')) - .then(() => app.browserWindow.isVisible()) - .then((val) => t.equal(val, true, 'isVisible')) - .then(() => app.browserWindow.isFocused()) - .then((val) => t.equal(val, true, 'isFocused')) - .then(() => app.browserWindow.getBounds()) - .then((val) => t.notEqual(val.width, 0, 'getBounds')) - .then(() => app.browserWindow.getBounds()) - .then((val) => t.notEqual(val.height, 0, 'getBounds')) + .then(() => Promise.all([ + t.resolveMatch(app.browserWindow.isVisible(), true, 'isVisible'), + t.resolveMatch(app.client.getWindowCount(), 1, 'getWindowCount'), + t.resolveMatch(app.browserWindow.isMinimized(), false, 'isMinimized'), + t.resolveMatch(app.browserWindow.isDevToolsOpened(), false, 'isDevToolsOpened'), + t.resolveMatch(app.browserWindow.isVisible(), true, 'isVisible'), + t.resolveMatch(app.browserWindow.isFocused(), true, 'isFocused'), + t.resolveMatch(app.browserWindow.getBounds().then(bounds => bounds.width !== 0), true, 'getBounds'), + t.resolveMatch(app.browserWindow.getBounds().then(bounds => bounds.height !== 0), true, 'getBounds') + ])) .catch(e => t.fail(e)) .then(() => endTest(app)) }) @@ -39,16 +33,13 @@ tap('onboarding', function (t) { t.test('intro should show every time you open the app as long as you have no dats', function (t) { var app = createApp() return waitForLoad(app) - .then(() => app.browserWindow.isVisible()) - .then((isVisible) => t.ok(isVisible, 'isVisible')) - .then(() => app.browserWindow.getTitle()) - .then((title) => t.equal(title, 'Dat Desktop | Welcome', 'correct title')) + .then(() => t.resolveMatch(app.browserWindow.isVisible(), true, 'isVisible')) + .then(() => t.resolveMatch(app.browserWindow.getTitle(), 'Dat Desktop | Welcome', 'correct title')) .then(() => app.client.click('button')) .then(() => wait()) .then(() => app.client.click('button[title="Skip Intro"]')) .then(() => wait()) - .then(() => app.browserWindow.getTitle()) - .then((title) => t.equal(title, 'Dat Desktop', 'correct title')) + .then(() => t.resolveMatch(app.browserWindow.getTitle(), 'Dat Desktop', 'correct title')) .then(() => app.stop()) .then(() => Promise.resolve(app = createApp())) .then(() => waitForLoad(app)) @@ -65,8 +56,7 @@ tap('onboarding', function (t) { tap('working with dats', function (t) { var app = createApp() return waitForLoad(app) - .then(() => app.browserWindow.isVisible()) - .then((isVisible) => t.ok(isVisible, 'isVisible')) + .then(() => t.resolveMatch(app.browserWindow.isVisible(), true, 'isVisible')) .then(() => app.client.click('button')) .then(() => wait(4000)) .then(() => app.client.click('button[title="Skip Intro"]')) @@ -83,8 +73,7 @@ tap('working with dats', function (t) { .then(() => app.client.click('button[title="Share Dat"]')) .then(() => app.client.click('button[title="Copy to Clipboard"]')) .then(() => wait()) - .then(() => clipboard.read()) - .then(text => t.ok(text.match(/^dat:\/\/[0-9a-f]{32}/), 'link copied to clipboard')) + .then(() => t.resolveMatch(clipboard.read(), /^dat:\/\/[0-9a-f]{32}/, 'link copied to clipboard')) .then(() => app.stop()) .then(() => Promise.resolve(app = createApp())) .then(() => waitForLoad(app)) From e7aade0c0ee5b4c785bcc9b68dc8847f20bb58ab Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Thu, 25 Jan 2018 23:32:52 +0900 Subject: [PATCH 09/17] Extracted wait into until --- tests/index.js | 9 +-------- tests/utils/wait.js | 7 +++++++ 2 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 tests/utils/wait.js diff --git a/tests/index.js b/tests/index.js index 3012dc47..dd18444b 100755 --- a/tests/index.js +++ b/tests/index.js @@ -5,6 +5,7 @@ var path = require('path') var tap = require('tap').test var del = require('del') var { execSync } = require('child_process') +var wait = require('./utils/wait') var TEST_DATA = path.join(__dirname, 'test_data') var TEST_DATA_DB = path.join(TEST_DATA, 'multidat.json') @@ -119,14 +120,6 @@ function waitForLoad (app, t) { }) } -// Returns a promise that resolves after 'ms' milliseconds. Default: 1 second -function wait (ms) { - ms = ms || 3000 - return new Promise(function (resolve, reject) { - setTimeout(resolve, ms) - }) -} - // Quit the app, end the test, either in success (!err) or failure (err) function endTest (app) { var fixPath = path.join(__dirname, 'fixtures') diff --git a/tests/utils/wait.js b/tests/utils/wait.js new file mode 100644 index 00000000..b2b840e0 --- /dev/null +++ b/tests/utils/wait.js @@ -0,0 +1,7 @@ +// Returns a promise that resolves after 'ms' milliseconds. Default: 1 second +module.exports = function wait (ms) { + ms = ms || 3000 + return new Promise(function (resolve, reject) { + setTimeout(resolve, ms) + }) +} From 745085b02cad90b18891ab16233b9b322b9e8e65 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Thu, 25 Jan 2018 23:27:36 +0900 Subject: [PATCH 10/17] =?UTF-8?q?Using=20waitForAndClick=20to=20get=20clea?= =?UTF-8?q?ner,=20quicker=20tests=20that=20don=E2=80=99t=20fail.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/index.js | 15 ++++++--------- tests/utils/waitForAndClick.js | 10 ++++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 tests/utils/waitForAndClick.js diff --git a/tests/index.js b/tests/index.js index dd18444b..f87fa541 100755 --- a/tests/index.js +++ b/tests/index.js @@ -6,6 +6,7 @@ var tap = require('tap').test var del = require('del') var { execSync } = require('child_process') var wait = require('./utils/wait') +var waitForAndClick = require('./utils/waitForAndClick') var TEST_DATA = path.join(__dirname, 'test_data') var TEST_DATA_DB = path.join(TEST_DATA, 'multidat.json') @@ -38,8 +39,7 @@ tap('onboarding', function (t) { .then(() => t.resolveMatch(app.browserWindow.getTitle(), 'Dat Desktop | Welcome', 'correct title')) .then(() => app.client.click('button')) .then(() => wait()) - .then(() => app.client.click('button[title="Skip Intro"]')) - .then(() => wait()) + .then(() => waitForAndClick(t, app, 'button[title="Skip Intro"]')) .then(() => t.resolveMatch(app.browserWindow.getTitle(), 'Dat Desktop', 'correct title')) .then(() => app.stop()) .then(() => Promise.resolve(app = createApp())) @@ -58,11 +58,9 @@ tap('working with dats', function (t) { var app = createApp() return waitForLoad(app) .then(() => t.resolveMatch(app.browserWindow.isVisible(), true, 'isVisible')) - .then(() => app.client.click('button')) - .then(() => wait(4000)) - .then(() => app.client.click('button[title="Skip Intro"]')) - .then(() => wait()) - .then(() => app.client.click('button')) // create new + .then(() => waitForAndClick(t, app, 'button[title="Get Started"]')) + .then(() => waitForAndClick(t, app, 'button[title="Skip Intro"]')) + .then(() => waitForAndClick(t, app, 'button')) .then(() => wait()) .then(() => app.client.getText('.size')) .then((text) => { @@ -85,8 +83,7 @@ tap('working with dats', function (t) { .then((text) => { t.ok(text.match(/(126|52) B/), 'contains correct size') }) - .then(() => wait()) - .then(() => app.client.click('button.delete')) + .then(() => waitForAndClick(t, app, 'button.delete')) .then(() => app.client.click('button.cancel-button')) .then(() => app.client.click('button.delete')) .then(() => app.client.click('button.confirm-button')) diff --git a/tests/utils/waitForAndClick.js b/tests/utils/waitForAndClick.js new file mode 100644 index 00000000..8f14bf76 --- /dev/null +++ b/tests/utils/waitForAndClick.js @@ -0,0 +1,10 @@ +module.exports = function waitForAndClick (t, app, selector, ms, reverse) { + return app.client.waitForExist(selector, ms, reverse) + .then(function () { + t.ok(true, selector + ' exists.') + return app.client.click(selector) + .then(function () { + t.ok(true, selector + ' clicked.') + }) + }) +} From 7a2a02f9d3caacf22ffdbb7973d38b010e1b4e87 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Fri, 26 Jan 2018 01:59:55 +0900 Subject: [PATCH 11/17] =?UTF-8?q?Using=20waitForMatch=20to=20quicker=20fin?= =?UTF-8?q?d=20out=20if=20a=20match=20exist=20and=20don=E2=80=99t=20fail?= =?UTF-8?q?=20the=20test=20if=20the=20text=20happens=20to=20show=20somethi?= =?UTF-8?q?ng=20different=20in-between=20(like=20the=20loading=20bytes)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/index.js | 22 ++++++---------------- tests/utils/waitForMatch.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 tests/utils/waitForMatch.js diff --git a/tests/index.js b/tests/index.js index f87fa541..1cd66b31 100755 --- a/tests/index.js +++ b/tests/index.js @@ -5,8 +5,9 @@ var path = require('path') var tap = require('tap').test var del = require('del') var { execSync } = require('child_process') -var wait = require('./utils/wait') var waitForAndClick = require('./utils/waitForAndClick') +var waitForMatch = require('./utils/waitForMatch') +var wait = require('./utils/wait') var TEST_DATA = path.join(__dirname, 'test_data') var TEST_DATA_DB = path.join(TEST_DATA, 'multidat.json') @@ -61,13 +62,8 @@ tap('working with dats', function (t) { .then(() => waitForAndClick(t, app, 'button[title="Get Started"]')) .then(() => waitForAndClick(t, app, 'button[title="Skip Intro"]')) .then(() => waitForAndClick(t, app, 'button')) - .then(() => wait()) - .then(() => app.client.getText('.size')) - .then((text) => { - t.ok(text.match(/(126|52) B/), 'contains correct size') - }) - .then(() => app.client.getText('.network')) - .then((text) => t.ok(text.match(/0/), 'contains network size')) + .then(() => waitForMatch(t, app, '.size', /(126|52) B/) + .then(() => waitForMatch(t, app, '.network', /0/))) .then(() => clipboard.write('')) .then(() => app.client.click('button[title="Share Dat"]')) .then(() => app.client.click('button[title="Copy to Clipboard"]')) @@ -78,18 +74,12 @@ tap('working with dats', function (t) { .then(() => waitForLoad(app)) .then(() => app.browserWindow.isVisible()) .then((isVisible) => t.equal(isVisible, true, 'reloaded and is visible')) - .then(() => wait()) - .then(() => app.client.getText('.size')) - .then((text) => { - t.ok(text.match(/(126|52) B/), 'contains correct size') - }) + .then(() => waitForMatch(t, app, '.size', /(126|52) B/)) .then(() => waitForAndClick(t, app, 'button.delete')) .then(() => app.client.click('button.cancel-button')) .then(() => app.client.click('button.delete')) .then(() => app.client.click('button.confirm-button')) - .then(() => wait()) - .then(() => app.client.getText('.tutorial')) - .then((text) => t.ok(text.toLowerCase().match(/share/), 'now the dat is gone and welcome screen is back')) + .then(() => waitForMatch(t, app, '.tutorial', /share/i)) // now the dat is gone and welcome screen is back .catch(e => t.fail(e)) .then(() => endTest(app)) }) diff --git a/tests/utils/waitForMatch.js b/tests/utils/waitForMatch.js new file mode 100644 index 00000000..9a6dedba --- /dev/null +++ b/tests/utils/waitForMatch.js @@ -0,0 +1,33 @@ +var wait = require('./wait') + +module.exports = function waitForMatch (t, app, selector, regexp, ms, reverse) { + if (reverse) { + reverse = true + } else { + reverse = false + } + if (!ms) { + ms = 10000 + } + var lastValue + var end = Date.now() + ms + function check () { + if (Date.now() > end) { + return Promise.reject(new Error('Timeout after ' + ms + 'ms tryin to match "' + selector + '" with ' + String(regexp) + '; last value: ' + lastValue)) + } + return app.client.getText(selector) + .then(function (text) { + lastValue = text + var match = regexp.test(text) ? !reverse : reverse + if (!match) { + return Promise.reject(new Error('no-match')) + } + t.ok(true, '"' + selector + '" matches ' + String(regexp)) + return Promise.resolve(text) + }) + .catch(function (e) { + return wait(100).then(check) + }) + } + return check() +} From e4ad97e853c8e0023ea168390aff09a5d9d3e8f9 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Thu, 25 Jan 2018 23:56:42 +0900 Subject: [PATCH 12/17] The Default wait period is too long in those cases --- tests/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/index.js b/tests/index.js index 1cd66b31..5a4d5521 100755 --- a/tests/index.js +++ b/tests/index.js @@ -39,7 +39,7 @@ tap('onboarding', function (t) { .then(() => t.resolveMatch(app.browserWindow.isVisible(), true, 'isVisible')) .then(() => t.resolveMatch(app.browserWindow.getTitle(), 'Dat Desktop | Welcome', 'correct title')) .then(() => app.client.click('button')) - .then(() => wait()) + .then(() => wait(200)) .then(() => waitForAndClick(t, app, 'button[title="Skip Intro"]')) .then(() => t.resolveMatch(app.browserWindow.getTitle(), 'Dat Desktop', 'correct title')) .then(() => app.stop()) @@ -67,7 +67,7 @@ tap('working with dats', function (t) { .then(() => clipboard.write('')) .then(() => app.client.click('button[title="Share Dat"]')) .then(() => app.client.click('button[title="Copy to Clipboard"]')) - .then(() => wait()) + .then(() => wait(200)) .then(() => t.resolveMatch(clipboard.read(), /^dat:\/\/[0-9a-f]{32}/, 'link copied to clipboard')) .then(() => app.stop()) .then(() => Promise.resolve(app = createApp())) From 6867714dc75c339a339fba970cb8b9f6e57bad1f Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Thu, 25 Jan 2018 23:57:50 +0900 Subject: [PATCH 13/17] Using waitForExist for quicker results. --- tests/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/index.js b/tests/index.js index 5a4d5521..1d48952a 100755 --- a/tests/index.js +++ b/tests/index.js @@ -47,8 +47,7 @@ tap('onboarding', function (t) { .then(() => waitForLoad(app)) .then(() => app.browserWindow.isVisible()) .then(() => app.client.click('button')) - .then(() => wait()) - .then(() => app.client.getText('button[title="Skip Intro"]')) + .then(() => app.client.waitForExist('button[title="Skip Intro"]')) .catch(e => t.fail(e)) .then(() => endTest(app)) }) From 246804a3e534b9a79f6f492c94203779e43ccb56 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Fri, 26 Jan 2018 01:42:11 +0900 Subject: [PATCH 14/17] Using tap for all tests. --- package-lock.json | 194 ------------------------------------------- package.json | 2 - tests/dat-manager.js | 12 +-- tests/intro.js | 8 +- 4 files changed, 10 insertions(+), 206 deletions(-) diff --git a/package-lock.json b/package-lock.json index 721b0c6a..87f0c08b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1907,12 +1907,6 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, - "deep-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", - "dev": true - }, "deep-extend": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", @@ -1939,16 +1933,6 @@ "clone": "1.0.3" } }, - "define-properties": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", - "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", - "dev": true, - "requires": { - "foreach": "2.0.5", - "object-keys": "1.0.11" - } - }, "defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", @@ -2587,30 +2571,6 @@ "is-arrayish": "0.2.1" } }, - "es-abstract": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.10.0.tgz", - "integrity": "sha512-/uh/DhdqIOSkAWifU+8nG78vlQxdLckUdI/sPgy0VhuXi2qJ7T8czBmqIYtLQVpCIFYafChnsRsB5pyb1JdmCQ==", - "dev": true, - "requires": { - "es-to-primitive": "1.1.1", - "function-bind": "1.1.1", - "has": "1.0.1", - "is-callable": "1.1.3", - "is-regex": "1.0.4" - } - }, - "es-to-primitive": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz", - "integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=", - "dev": true, - "requires": { - "is-callable": "1.1.3", - "is-date-object": "1.0.1", - "is-symbol": "1.0.1" - } - }, "es5-ext": { "version": "0.10.37", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.37.tgz", @@ -4945,18 +4905,6 @@ "builtin-modules": "1.1.1" } }, - "is-callable": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.3.tgz", - "integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI=", - "dev": true - }, - "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", - "dev": true - }, "is-dom": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/is-dom/-/is-dom-1.0.9.tgz", @@ -5119,15 +5067,6 @@ "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", "dev": true }, - "is-regex": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", - "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", - "dev": true, - "requires": { - "has": "1.0.1" - } - }, "is-relative": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", @@ -5158,12 +5097,6 @@ "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, - "is-symbol": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", - "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", - "dev": true - }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -8881,12 +8814,6 @@ "strip-json-comments": "2.0.1" } }, - "re-emitter": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/re-emitter/-/re-emitter-1.1.3.tgz", - "integrity": "sha1-+p4xn/3u6zWycpbvDz03TawvUqc=", - "dev": true - }, "read-all-stream": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/read-all-stream/-/read-all-stream-3.1.0.tgz", @@ -9180,15 +9107,6 @@ "onetime": "1.1.0" } }, - "resumer": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", - "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", - "dev": true, - "requires": { - "through": "2.3.8" - } - }, "rgb2hex": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/rgb2hex/-/rgb2hex-0.1.0.tgz", @@ -9920,17 +9838,6 @@ "strip-ansi": "3.0.1" } }, - "string.prototype.trim": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", - "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", - "dev": true, - "requires": { - "define-properties": "1.1.2", - "es-abstract": "1.10.0", - "function-bind": "1.1.1" - } - }, "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", @@ -10186,29 +10093,6 @@ } } }, - "tap-out": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/tap-out/-/tap-out-1.4.2.tgz", - "integrity": "sha1-yQfsG/lAURHQiCY+kvVgi4jLs3o=", - "dev": true, - "requires": { - "re-emitter": "1.1.3", - "readable-stream": "2.3.3", - "split": "1.0.1", - "trim": "0.0.1" - }, - "dependencies": { - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "dev": true, - "requires": { - "through": "2.3.8" - } - } - } - }, "tap-parser": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-7.0.0.tgz", @@ -10220,84 +10104,6 @@ "minipass": "2.2.1" } }, - "tap-spec": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/tap-spec/-/tap-spec-4.1.1.tgz", - "integrity": "sha1-4unyb1IIIysfViKIyXYk1YqI8Fo=", - "dev": true, - "requires": { - "chalk": "1.1.3", - "duplexer": "0.1.1", - "figures": "1.7.0", - "lodash": "3.10.1", - "pretty-ms": "2.1.0", - "repeat-string": "1.6.1", - "tap-out": "1.4.2", - "through2": "2.0.3" - }, - "dependencies": { - "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", - "dev": true, - "requires": { - "escape-string-regexp": "1.0.5", - "object-assign": "4.1.1" - } - }, - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "tape": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/tape/-/tape-4.8.0.tgz", - "integrity": "sha512-TWILfEnvO7I8mFe35d98F6T5fbLaEtbFTG/lxWvid8qDfFTxt19EBijWmB4j3+Hoh5TfHE2faWs73ua+EphuBA==", - "dev": true, - "requires": { - "deep-equal": "1.0.1", - "defined": "1.0.0", - "for-each": "0.3.2", - "function-bind": "1.1.1", - "glob": "7.1.2", - "has": "1.0.1", - "inherits": "2.0.3", - "minimist": "1.2.0", - "object-inspect": "1.3.0", - "resolve": "1.4.0", - "resumer": "0.0.0", - "string.prototype.trim": "1.1.2", - "through": "2.3.8" - }, - "dependencies": { - "object-inspect": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.3.0.tgz", - "integrity": "sha512-OHHnLgLNXpM++GnJRyyhbr2bwl3pPVm4YvaraHrRvDt/N3r+s/gDVHciA7EJBTkijKXj61ssgSAikq1fb0IBRg==", - "dev": true - }, - "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", - "dev": true, - "requires": { - "path-parse": "1.0.5" - } - } - } - }, "tar-stream": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.5.5.tgz", diff --git a/package.json b/package.json index dbd0148a..eba9bb37 100644 --- a/package.json +++ b/package.json @@ -73,8 +73,6 @@ "spok": "^0.7.0", "standard": "^7.1.2", "tap": "^11.0.1", - "tap-spec": "^4.1.1", - "tape": "^4.6.3", "through2": "^2.0.3", "watchify": "^3.7.0" }, diff --git a/tests/dat-manager.js b/tests/dat-manager.js index 057f12ed..f6a674be 100755 --- a/tests/dat-manager.js +++ b/tests/dat-manager.js @@ -1,9 +1,13 @@ #!/usr/bin/env node node_modules/.bin/electron -var tape = require('tape') +var tap = require('tap') +var test = tap.test var Multidat = require('multidat') var toilet = require('toiletdb/inmemory') var Manager = require('../lib/dat-manager') +tap.on('result', function (res) { + process.exit(res.ok ? 0 : 1) +}) function setup (db, dbPaused, cb) { if (typeof db === 'function') { @@ -22,7 +26,7 @@ function setup (db, dbPaused, cb) { }) } -tape('dat-manager', function (t) { +test('dat-manager', function (t) { t.test('Manager({ multidat, dbPaused, onupdate })', function (t) { t.test('assert arguments', function (t) { setup(function (err, { multidat, dbPaused }) { @@ -267,11 +271,7 @@ tape('dat-manager', function (t) { }) }) }) - }) - - t.test('finish', function (t) { t.end() - process.exit(Number(!t._ok)) }) t.end() diff --git a/tests/intro.js b/tests/intro.js index f0126517..93611292 100755 --- a/tests/intro.js +++ b/tests/intro.js @@ -1,11 +1,11 @@ #!/usr/bin/env node var EventEmitter = require('events').EventEmitter -var tape = require('tape') +var test = require('tap').test var spok = require('spok') var intro = require('../models/intro') -tape('models/intro: should initialize with a default state', function (t) { +test('models/intro: should initialize with a default state', function (t) { var state = {} var emitter = new EventEmitter() intro(state, emitter) @@ -17,7 +17,7 @@ tape('models/intro: should initialize with a default state', function (t) { t.end() }) -tape('should show intro screen if there are no dats', function (t) { +test('should show intro screen if there are no dats', function (t) { var state = { dats: { values: [] @@ -37,7 +37,7 @@ tape('should show intro screen if there are no dats', function (t) { t.end() }) -tape('should be able to hide the intro screen', function (t) { +test('should be able to hide the intro screen', function (t) { var state = { intro: { show: true From 349fbbb750f04cd89db822d4ba14036e969692d7 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Fri, 26 Jan 2018 02:19:47 +0900 Subject: [PATCH 15/17] shebang error on windows --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index eba9bb37..d1cbcf0d 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,8 @@ "build-background": "node scripts/build.js background", "start": "cross-env NODE_ENV=development electron .", "test": "standard && npm run deps && npm run test:unit && npm run test:integration", - "test:integration": "./tests/index.js", - "test:unit": "./tests/dat-manager.js && ./tests/intro.js", + "test:integration": "node ./tests/index.js", + "test:unit": "electron ./tests/dat-manager.js && node ./tests/intro.js", "postinstall": "node scripts/build.js postinstall", "pack": "build --dir", "dist": "build --publish=onTagOrDraft" From 3486a3c53c1d38d42f196a3bcadbe35696340cfa Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Mon, 29 Jan 2018 13:58:00 +0900 Subject: [PATCH 16/17] Better error logs on windows tests --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 931e9d3c..e0f54fee 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,6 @@ environment: + ELECTRON_ENABLE_STACK_DUMPING: 'true' + DEBUG: '*,-nugget*,-eslint*,-extract-zip*,-sumchecker*,-electron-download*,-dependency-check*' matrix: - nodejs_version: "8" From 3c2d9993039d1e1f964d2fa4643f115b3a5c164f Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Tue, 30 Jan 2018 09:59:08 +0900 Subject: [PATCH 17/17] Updated spectron --- package-lock.json | 46 +++++++++++++++++++++++----------------------- package.json | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 87f0c08b..2033d611 100644 --- a/package-lock.json +++ b/package-lock.json @@ -406,8 +406,8 @@ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", "dev": true, "requires": { - "core-js": "2.5.1", - "regenerator-runtime": "0.11.0" + "core-js": "2.5.3", + "regenerator-runtime": "0.11.1" } }, "balanced-match": { @@ -1333,9 +1333,9 @@ "integrity": "sha1-aWYs0wVJPJJcAqOEy8rnbWQtd/M=" }, "core-js": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz", - "integrity": "sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs=", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", + "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=", "dev": true }, "core-util-is": { @@ -2385,9 +2385,9 @@ } }, "electron-chromedriver": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/electron-chromedriver/-/electron-chromedriver-1.7.1.tgz", - "integrity": "sha1-AIyXl2AHqk6xhJHuCV6U0X7kdhA=", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/electron-chromedriver/-/electron-chromedriver-1.8.0.tgz", + "integrity": "sha512-m1f3nle5MaGp94bcDTtMZZMMOgPO54+TXoPBlTbBSUjfINR5SJ46yQXLfuE79/qsFfJKslZB1UzWURDDFIRmpQ==", "dev": true, "requires": { "electron-download": "4.1.0", @@ -8965,9 +8965,9 @@ } }, "regenerator-runtime": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz", - "integrity": "sha512-/aA0kLeRb5N9K0d4fw7ooEbI+xDe+DKD499EQqygGqeS8N3xto15p09uY2xj7ixP81sNPXvRLnAQIqdVStgb1A==", + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", "dev": true }, "regex-cache": { @@ -9475,16 +9475,16 @@ "dev": true }, "spectron": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/spectron/-/spectron-3.7.2.tgz", - "integrity": "sha1-hvQTBqm3DtbuFQD399Otw4mvtEY=", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/spectron/-/spectron-3.8.0.tgz", + "integrity": "sha512-fQ7gFp6UuEaONjXFLifLeIUI022pOsm3b+NFAm696r2umUkSZ9IbnEgHwrvBX+pJ3QUDyCEs5bPHUieYU7FvaQ==", "dev": true, "requires": { "dev-null": "0.1.1", - "electron-chromedriver": "1.7.1", + "electron-chromedriver": "1.8.0", "request": "2.83.0", "split": "1.0.1", - "webdriverio": "4.9.11" + "webdriverio": "4.10.1" }, "dependencies": { "split": { @@ -10760,12 +10760,12 @@ "dev": true }, "webdriverio": { - "version": "4.9.11", - "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-4.9.11.tgz", - "integrity": "sha1-qChxPFpEvpmvvgfrW1I9XszQS0Q=", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-4.10.1.tgz", + "integrity": "sha1-Qvekh7czebJ0Oi+uULMUJhX2EXA=", "dev": true, "requires": { - "archiver": "2.1.0", + "archiver": "2.1.1", "babel-runtime": "6.26.0", "css-parse": "2.0.0", "css-value": "0.0.1", @@ -10790,9 +10790,9 @@ }, "dependencies": { "archiver": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/archiver/-/archiver-2.1.0.tgz", - "integrity": "sha1-0t8ujVdzqCwdzOklzMQUUOqZmv0=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/archiver/-/archiver-2.1.1.tgz", + "integrity": "sha1-/2YrSnggFJSj7lRNOjP+dJZQnrw=", "dev": true, "requires": { "archiver-utils": "1.3.0", diff --git a/package.json b/package.json index d1cbcf0d..6edfe5b8 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "nodemon": "^1.9.2", "npm-run-path": "^2.0.2", "sheetify-nested": "^1.0.2", - "spectron": "^3.5.0", + "spectron": "^3.8.0", "spok": "^0.7.0", "standard": "^7.1.2", "tap": "^11.0.1",