Use NODE_ENV to test for test environment; improve scripts
This commit is contained in:
parent
014ae76634
commit
ae91897ead
@ -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",
|
||||
|
12
npm
12
npm
@ -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 $@
|
||||
|
@ -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"
|
||||
|
@ -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}`);
|
@ -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}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user