Commit a4364ce4 authored by Alf Eaton's avatar Alf Eaton
Browse files

Merge remote-tracking branch 'origin/master' into reducer-import-export

parents bb4f5398 2f24bc52
image: pubsweet/pubsweet-test-base
before_script:
- apt-get update -y
- apt-get install -y libssl-dev build-essential wget
- npm install -g node-gyp
- npm install -g mocha
- npm install
- yarn
test:
script:
- npm run test
- xvfb-run --server-args "-screen 0 1024x768x24" yarn run testdocker
......@@ -4,7 +4,9 @@
"main": "src/index.js",
"scripts": {
"compile": "babel --presets es2015,react -d lib/ src/",
"test": "./test/helpers/setup.js && NODE_ENV=test jest; ./test/helpers/cleanup.js",
"test": "./test/helpers/runtestcmd jest",
"testdocker": "./test/helpers/runtestcmd \"jest --runInBand --no-watchman --no-cache --verbose --forceExit\"",
"testci": "gitlab-ci-multi-runner exec docker --docker-image=pubsweet/pubsweet-test-base test",
"eslint": "eslint"
},
"engines": {
......@@ -53,8 +55,6 @@
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-eslint": "^6.1.2",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"eslint": "^3.2.2",
......@@ -68,10 +68,12 @@
"expose-loader": "^0.7.0",
"file-api": "^0.10.4",
"formdata-polyfill": "^1.0.4",
"isomorphic-form-data": "^1.0.0",
"jest": "^19.0.1",
"node-localstorage": "^1.3.0",
"pubsweet": "git+https://gitlab.coko.foundation/pubsweet/pubsweet-cli.git#testing",
"pubsweet-cli": "git+https://gitlab.coko.foundation/pubsweet/pubsweet-cli.git#testing",
"pubsweet-component-login": "^0.1.0",
"pubsweet-server": "^0.7.2",
"require-dir": "^0.3.1",
"standard": "^8.0.0-beta.5",
"supertest": "^2.0.0",
......
......@@ -27,7 +27,7 @@ const describeAction = actions => (key, opts, cb) => {
secondarg: empty,
types: {},
properties: {},
user: require.requireActual('pubsweet/test/fixtures').adminUser
user: require.requireActual('pubsweet-cli/test/fixtures').adminUser
})
describe(key, () => {
......
......@@ -2,7 +2,7 @@ const fs = require('fs')
const path = require('path')
const mockdatafile = path.join(__dirname, 'mockapp.json')
const startnewapp = require('pubsweet/test/helpers/startnewapp')
const startnewapp = require('./startnewapp')
startnewapp().then(
_app => {
......
#!/bin/sh
TESTCMD=$1
export NODE_ENV=test
./test/helpers/setup.js
echo "running test command $TESTCMD"
$TESTCMD
if [ $? -eq 0 ]
then
echo "test suite passed - cleaning up"
./test/helpers/cleanup.js
exit 0
else
echo "test suite failed - cleaning up"
./test/helpers/cleanup.js
exit 1
fi
......@@ -3,9 +3,10 @@
const path = require('path')
const childenv = Object.create(process.env)
childenv.NODE_ENV = 'production'
childenv.NODE_ENV = 'test'
try {
console.log('running')
const child = require('child_process').spawn(
'node', [path.join(__dirname, 'mockapp.js')],
{
......@@ -14,6 +15,7 @@ try {
env: childenv
}
)
console.log('run started')
child.stdout.on('data', data => {
const msg = data.toString('utf8')
......@@ -21,8 +23,15 @@ try {
console.log('Pubsweet app is running')
child.unref()
process.exit(0)
} else {
console.log('outdata', msg)
}
})
child.stderr.on('data', data => {
const msg = data.toString('utf8')
console.log('errdata', msg)
})
} catch (err) {
console.log('ERROR:', err.message)
console.log('TRACE:', err.stack)
......
const spawn = require('child-process').spawn
const spawn = require('child_process').spawnSync
const path = require('path')
const fs = require('fs-extra')
module.exports = () => require('pubsweet/test/helpers/working_dir')(
).then(
dir => require('pubsweet/src/generate-config')()
).then(
require('pubsweet/src/generate-env')
).then(
() => require('pubsweet/src/initial-app')('someapp')
).then(
require('pubsweet/src/setup-db')({
properties: require('pubsweet/src/db-properties'),
override: require('pubsweet/test/fixtures').dbconfig
const run = async () => {
const tmpdir = await require('pubsweet-cli/test/helpers/working_dir')()
const appname = 'testapp'
fs.mkdirsSync(path.join(tmpdir, appname))
console.log('created directory')
await require('pubsweet-cli/src/generate-config')()
console.log('config generated')
await require('pubsweet-cli/src/generate-env')()
console.log('env generated')
await require('pubsweet-cli/src/initial-app')(appname)
console.log('app generated')
const app = await require('pubsweet-cli/src/setup-db')({
properties: require('pubsweet-cli/src/db-properties'),
override: require('pubsweet-cli/test/fixtures').dbconfig
})
).then(
dbsetup => new Promise(
(resolve, reject) => spawn(
'npm install',
[path.join(__dirname, '..', '..')],
{
cwd: process.cwd(),
stdio: 'ignore',
shell: true
}
).then(
() => resolve(dbsetup)
).catch(
reject
)
)
).then(
dbsetup => new Promise(
resolve => require('pubsweet/test/src/start')(server => {
resolve({
server: server,
user: dbsetup.user,
collection: dbsetup.collection
})
})
console.log('db created')
require('pubsweet-cli/src/load-config')(path.resolve('', './config'))
console.log('config loaded')
spawn(
'npm install',
[path.join(__dirname, '..', '..')],
{
cwd: process.cwd(),
stdio: 'ignore',
shell: true
}
)
)
console.log('starting server')
return new Promise(resolve => {
require('pubsweet-cli/src/start')(() => resolve(app))
})
}
module.exports = run
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment