Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run test:integration:post controls execution of web server (like in the main openwhyd codebase) #21

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"start:coverage": "npx nyc --silent node app.js $@",
"test-reset": "node test/reset-test-db.js",
"test:integration": "npx mocha test/integration/*.js --serial --exit",
"test:integration:post": "START_WITH_ENV_FILE='./env-vars-testing.conf' mocha test/integration/*post.api.tests.js $@",
"test:unit": "npx mocha test/unit/*.js --exit",
"test-approval": "npx kill-port --port 8080 >/dev/null; DONT_KILL=1 START_WITH_ENV_FILE='./env-vars-testing.conf' ava test/approval.tests.js $@",
"test-approval-debug": "npm run test-approval -- --fail-fast --serial",
Expand Down
16 changes: 16 additions & 0 deletions test/integration/post.api.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,24 @@ const request = require('request');
var { DUMMY_USER, cleanup, URL_PREFIX } = require('../fixtures.js');
var api = require('../api-client.js');

var { START_WITH_ENV_FILE } = process.env;
const { startOpenwhydServer } = require('../approval-tests-helpers');

describe(`post api`, function () {
before(cleanup); // to prevent side effects between tests
let context = {};
before(async () => {
if (START_WITH_ENV_FILE) {
context.serverProcess = await startOpenwhydServer({
startWithEnv: START_WITH_ENV_FILE,
});
}
});
after(() => {
if (context.serverProcess?.kill) {
context.serverProcess.kill('SIGINT');
}
});

var pId, uId;
const post = {
Expand Down