flesh out tests

This commit is contained in:
Nolan Lawson 2018-02-18 12:03:37 -08:00
parent eadcdb0f3e
commit 704c4c8ca8
4 changed files with 32 additions and 111 deletions

View File

@ -7,7 +7,7 @@ const fs = require('fs')
const stat = pify(fs.stat.bind(fs)) const stat = pify(fs.stat.bind(fs))
const writeFile = pify(fs.writeFile.bind(fs)) const writeFile = pify(fs.writeFile.bind(fs))
const mkdirp = pify(require('mkdirp')) const mkdirp = pify(require('mkdirp'))
const fetch = require('node-fetch') const waitForMastodonToStart = require('./wait-for-mastodon-to-start')
const envFile = ` const envFile = `
PAPERCLIP_SECRET=foo PAPERCLIP_SECRET=foo
@ -68,18 +68,7 @@ async function runMastodon() {
console.error(data.toString('utf8').replace(/\n$/, '')) console.error(data.toString('utf8').replace(/\n$/, ''))
}) })
while (true) { await waitForMastodonToStart()
try {
let json = await ((await fetch('http://127.0.0.1:3000/api/v1/instance')).json())
if (json.uri) {
break
}
} catch (err) {
console.log('Waiting for Mastodon to start up...')
await new Promise(resolve => setTimeout(resolve, 1000))
}
}
console.log('Mastodon started up')
} }
async function main() { async function main() {

View File

@ -0,0 +1,25 @@
const fetch = require('node-fetch')
async function waitForMastodonToStart() {
while (true) {
try {
let json = await ((await fetch('http://127.0.0.1:3000/api/v1/instance')).json())
if (json.uri) {
break
}
} catch (err) {
console.log('Waiting for Mastodon to start up...')
await new Promise(resolve => setTimeout(resolve, 1000))
}
}
console.log('Mastodon started up')
}
module.exports = waitForMastodonToStart
if (require.main === module) {
waitForMastodonToStart().catch(err => {
console.error(err)
process.exit(1)
})
}

95
package-lock.json generated
View File

@ -1035,81 +1035,6 @@
"typedarray": "0.0.6" "typedarray": "0.0.6"
} }
}, },
"concurrently": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-3.5.1.tgz",
"integrity": "sha512-689HrwGw8Rbk1xtV9C4dY6TPJAvIYZbRbnKSAtfJ7tHqICFGoZ0PCWYjxfmerRyxBG0o3sbG3pe7N8vqPwIHuQ==",
"requires": {
"chalk": "0.5.1",
"commander": "2.6.0",
"date-fns": "1.29.0",
"lodash": "4.17.4",
"rx": "2.3.24",
"spawn-command": "0.0.2-1",
"supports-color": "3.2.3",
"tree-kill": "1.2.0"
},
"dependencies": {
"ansi-regex": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz",
"integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk="
},
"ansi-styles": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz",
"integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94="
},
"chalk": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz",
"integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=",
"requires": {
"ansi-styles": "1.1.0",
"escape-string-regexp": "1.0.5",
"has-ansi": "0.1.0",
"strip-ansi": "0.3.0",
"supports-color": "0.2.0"
},
"dependencies": {
"supports-color": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz",
"integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo="
}
}
},
"commander": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz",
"integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0="
},
"has-ansi": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz",
"integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=",
"requires": {
"ansi-regex": "0.2.1"
}
},
"strip-ansi": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz",
"integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=",
"requires": {
"ansi-regex": "0.2.1"
}
},
"supports-color": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz",
"integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=",
"requires": {
"has-flag": "1.0.0"
}
}
}
},
"console-browserify": { "console-browserify": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",
@ -1424,11 +1349,6 @@
} }
} }
}, },
"date-fns": {
"version": "1.29.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz",
"integrity": "sha512-lbTXWZ6M20cWH8N9S6afb0SBm6tMk+uUg6z3MqHPKE9atmsY3kJkTm8vKe93izJ2B2+q5MV990sM2CHgtAZaOw=="
},
"date-now": { "date-now": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
@ -6878,11 +6798,6 @@
"aproba": "1.2.0" "aproba": "1.2.0"
} }
}, },
"rx": {
"version": "2.3.24",
"resolved": "https://registry.npmjs.org/rx/-/rx-2.3.24.tgz",
"integrity": "sha1-FPlQpCF9fjXapxu8vljv9o6ksrc="
},
"rx-lite": { "rx-lite": {
"version": "3.1.2", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz",
@ -7512,11 +7427,6 @@
"resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz",
"integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=" "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM="
}, },
"spawn-command": {
"version": "0.0.2-1",
"resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz",
"integrity": "sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A="
},
"spdx-correct": { "spdx-correct": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz",
@ -8154,11 +8064,6 @@
"punycode": "1.4.1" "punycode": "1.4.1"
} }
}, },
"tree-kill": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.0.tgz",
"integrity": "sha512-DlX6dR0lOIRDFxI0mjL9IYg6OTncLm/Zt+JiBhE5OlFcAR8yc9S7FFXU9so0oda47frdM/JFsk7UjNt9vscKcg=="
},
"trim-newlines": { "trim-newlines": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz",

View File

@ -4,7 +4,8 @@
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"lint": "standard", "lint": "standard",
"dev": "npm run build-svg && concurrently --kill-others \"npm run build-sass-watch\" \"node server.js\"", "dev": "npm run build-svg && run-p --race build-sass-watch serve",
"serve": "node server.js",
"build": "npm run globalize-css && npm run build-sass && npm run build-svg && sapper build && npm run deglobalize-css", "build": "npm run globalize-css && npm run build-sass && npm run build-svg && sapper build && npm run deglobalize-css",
"start": "cross-env NODE_ENV=production node server.js", "start": "cross-env NODE_ENV=production node server.js",
"build-svg": "node ./bin/build-svg.js", "build-svg": "node ./bin/build-svg.js",
@ -13,7 +14,9 @@
"run-mastodon": "cd mastodon && docker-compose run --rm web rake db:migrate && docker-compose up", "run-mastodon": "cd mastodon && docker-compose run --rm web rake db:migrate && docker-compose up",
"cy:run": "cypress run", "cy:run": "cypress run",
"cy:open": "cypress open", "cy:open": "cypress open",
"test": "run-p --race dev cy:run", "test": "run-p --race run-mastodon dev test-mastodon",
"test-mastodon": "run-s wait-for-mastodon-to-start cy:run",
"wait-for-mastodon-to-start": "node bin/wait-for-mastodon-to-start.js",
"globalize-css": "node ./bin/globalize-css.js", "globalize-css": "node ./bin/globalize-css.js",
"deglobalize-css": "node ./bin/globalize-css.js --reverse", "deglobalize-css": "node ./bin/globalize-css.js --reverse",
"setup-mastodon": "node ./bin/setup-mastodon.js" "setup-mastodon": "node ./bin/setup-mastodon.js"
@ -25,7 +28,6 @@
"child-process-promise": "^2.2.1", "child-process-promise": "^2.2.1",
"chokidar": "^2.0.0", "chokidar": "^2.0.0",
"compression": "^1.7.1", "compression": "^1.7.1",
"concurrently": "^3.5.1",
"cross-env": "^5.1.3", "cross-env": "^5.1.3",
"css-loader": "^0.28.7", "css-loader": "^0.28.7",
"express": "^4.16.2", "express": "^4.16.2",