index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
-rw-r--r-- | jest.config.integ.cjs | 14 | ||||
-rwxr-xr-x | npm | 12 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | server.cjs (renamed from dev-server.cjs) | 9 | ||||
-rw-r--r-- | test/integration/setup.cjs | 2 |
5 files changed, 19 insertions, 20 deletions
diff --git a/jest.config.integ.cjs b/jest.config.integ.cjs index af5adf3..1b7b6a9 100644 --- a/jest.config.integ.cjs +++ b/jest.config.integ.cjs @@ -1,19 +1,5 @@ console.log("Jest config file read."); -// const { spawn } = require("child_process"); - -// const ls = spawn('ls', ['-lh', './test']); - -// ls.stdout.on('data', (data) => { console.log(`stdout: ${data}`); }); - -// ls.stderr.on('data', (data) => { -// console.error(`stderr: ${data}`); -// }); - -// ls.on('close', (code) => { -// console.log(`child process exited with code ${code}`); -// }); - module.exports = { globalSetup: "./test/integration/setup.cjs", globalTeardown: "./test/integration/teardown.cjs", @@ -1,3 +1,13 @@ #!/usr/bin/env bash -docker run --rm --init -it -v $PWD:/usr/src/app -u $(id -u):$(id -u) -p 8080:8080 btroops npm $@ +user_id=$(id -u) +image=btroops + +if [[ $1 == run && $2 == test* ]] +then + port=3005 +else + port=8080 +fi + +docker run --rm --init -it -v $PWD:/usr/src/app -u $user_id:$user_id -p $port:$port $image npm $@ diff --git a/package.json b/package.json index 1e0f59f..97e55ee 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "selenium-webdriver": "^4.19.0" }, "scripts": { - "start": "node dev-server.cjs", + "start": "node server.cjs", "test:integ": "node --trace-warnings ./node_modules/.bin/jest --detectOpenHandles --config jest.config.integ.cjs", "test:integ:debug": "NODE_INSPECT_RESUME_ON_START=1 node inspect ./node_modules/jest/bin/jest.js --config jest.config.integ.cjs --runInBand test/integration/page.test.js", "test": "jest" diff --git a/dev-server.cjs b/server.cjs index 2e7c2ec..b5bd00f 100644 --- a/dev-server.cjs +++ b/server.cjs @@ -1,13 +1,16 @@ const { createServer } = require('esbuild-server'); + const server = createServer( { bundle: true, entryPoints: ['src/index.js', 'src/map.js'], - outdir: 'build' + ...(process.env.NODE_ENV !== 'test') && { + outdir: 'build' + } }, { static: 'public', - ...(process.argv.slice(2).includes('--test')) && { + ...(process.env.NODE_ENV === 'test') && { port: 3005, injectLiveReload: false, watch: false @@ -24,4 +27,4 @@ server .catch(() => { console.error('Build failed'); }); -console.log(`Development server running at ${server.url}`); +console.log(`${process.env.NODE_ENV === 'test' ? 'Test' : 'Development'} server running at ${server.url}`); diff --git a/test/integration/setup.cjs b/test/integration/setup.cjs index c476077..a03d7de 100644 --- a/test/integration/setup.cjs +++ b/test/integration/setup.cjs @@ -2,7 +2,7 @@ console.log("\nSpawning server process..."); const { spawn } = require("child_process"); module.exports = async function () { - const child = spawn("node", ["dev-server.cjs", "--test"]); + const child = spawn("node", ["server.cjs"]); child.stdout.on('data', (data) => { console.log(`${data}`); |