mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Use node spawn to spin off several servers
This commit is contained in:
parent
a07f48826b
commit
9e4edca35b
@ -13,7 +13,8 @@
|
||||
"dev:debug": "nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js",
|
||||
"lint": "eslint src --config .eslintrc.js",
|
||||
"test": "nyc --reporter=text-lcov yarn run test:jest",
|
||||
"test:jest": "cross-env PERMISSIONS=disabled jest --forceExit --detectOpenHandles --runInBand",
|
||||
"test:jest": "jest --forceExit --detectOpenHandles --runInBand",
|
||||
"test:jest:debug": "node --inspect-brk ./node_modules/.bin/jest -i --forceExit --detectOpenHandles --runInBand",
|
||||
"test:coverage": "nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"db:script:seed": "wait-on tcp:4001 && babel-node src/seed/seed-db.js",
|
||||
"db:script:reset": "wait-on tcp:4001 && babel-node src/seed/reset-db.js",
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { request } from 'graphql-request'
|
||||
import fetch from 'node-fetch'
|
||||
|
||||
export const host = 'http://127.0.0.1:4123'
|
||||
|
||||
|
||||
@ -1,18 +1,36 @@
|
||||
const createServer = require('../../dist/server.js').default
|
||||
let app
|
||||
let permissionlessApp
|
||||
const { spawn } = require('child_process')
|
||||
const waitOn = require('wait-on')
|
||||
|
||||
let server
|
||||
let seeder
|
||||
|
||||
const setup = async function () {
|
||||
const server = createServer()
|
||||
app = await server.start({ port: 4123 })
|
||||
server = spawn('node', ['dist/'], {
|
||||
env: Object.assign({}, process.env, {
|
||||
GRAPHQL_URI: 'http://localhost:4123',
|
||||
GRAPHQL_PORT: '4123'
|
||||
})
|
||||
})
|
||||
|
||||
const permissionless = createServer()
|
||||
permissionlessApp = await server.start({ port: 4001 })
|
||||
seeder = spawn('node', ['dist/'], {
|
||||
env: Object.assign({}, process.env, {
|
||||
GRAPHQL_URI: 'http://localhost:4001',
|
||||
GRAPHQL_PORT: '4001',
|
||||
PERMISSIONS: 'disabled'
|
||||
})
|
||||
})
|
||||
|
||||
try {
|
||||
await waitOn({
|
||||
resources: ['http://localhost:4123', 'http://localhost:4001']
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
|
||||
const teardown = async function () {
|
||||
await app.close()
|
||||
await permissionlessApp.close()
|
||||
[server, seeder].forEach(app => app.kill())
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { create, cleanDatabase } from '../seed/factories'
|
||||
import { host, authenticatedHeaders, queryServer } from '../jest/helpers'
|
||||
import { host, authenticatedHeaders } from '../jest/helpers'
|
||||
import { GraphQLClient } from 'graphql-request'
|
||||
|
||||
describe('authorization', () => {
|
||||
@ -23,7 +23,7 @@ describe('authorization', () => {
|
||||
let headers = {}
|
||||
const action = async (headers) => {
|
||||
const graphQLClient = new GraphQLClient(host, { headers })
|
||||
return await graphQLClient.request(`{
|
||||
return graphQLClient.request(`{
|
||||
User(email: "owner@example.org") {
|
||||
email
|
||||
}
|
||||
|
||||
@ -5420,7 +5420,7 @@ node-fetch@2.1.2:
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5"
|
||||
integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=
|
||||
|
||||
node-fetch@^2.1.2, node-fetch@^2.2.0, node-fetch@^2.3.0:
|
||||
node-fetch@^2.1.2, node-fetch@^2.2.0, node-fetch@~2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5"
|
||||
integrity sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user