Skip to content

Commit 8f6100e

Browse files
committed
chore(test): add env config for testing
1 parent ef2e960 commit 8f6100e

7 files changed

Lines changed: 31 additions & 21 deletions

File tree

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TEST_SERVER_HOST="http://localhost"
2+
TEST_SERVER_PORT=3001

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Create and publish a Docker image
44
# Configures this workflow to run every time a change is pushed to the branch called `release`.
55
on:
66
push:
7-
tags: v0.*
7+
tags: v[0-9]+.[0-9]+.[0-9]+
88

99
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
1010
env:

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"license": "ISC",
1313
"dependencies": {
1414
"cors": "^2.8.5",
15+
"dotenv": "^16.4.5",
1516
"express": "^4.18.3",
1617
"slonik": "^40.2.1",
1718
"slonik-utilities": "^2.0.2",

tests/drafts.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { expect, describe, it } from "vitest";
2+
import { TEST_SERVER_URL } from "./global.setup";
3+
4+
describe('test suite works', () => {
5+
it("should return all proposals", async () => {
6+
const res = await fetch(TEST_SERVER_URL);
7+
const data = await res.json();
8+
expect(res.status).toEqual(200);
9+
// expect(data).toEqual({ message: "Paginated list of proposals" });
10+
});
11+
})

tests/global.setup.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import 'dotenv/config'
12
import { createServer } from "http";
23
import app from "../app";
34
let server;
45

6+
export const TEST_SERVER_URL = `${process.env.TEST_SERVER_HOST}:${process.env.TEST_SERVER_PORT}`
7+
58
export async function setup() {
69
server = createServer(app);
7-
server.listen(3000);
10+
server.listen(process.env.TEST_SERVER_PORT);
811
}
912

1013
export async function teardown() {

tests/topics.test.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)