Skip to content

Commit

Permalink
chore(test): add env config for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
zenlex committed May 12, 2024
1 parent ef2e960 commit 8f6100e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TEST_SERVER_HOST="http://localhost"
TEST_SERVER_PORT=3001
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Create and publish a Docker image
# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
push:
tags: v0.*
tags: v[0-9]+.[0-9]+.[0-9]+

# 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.
env:
Expand Down
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.18.3",
"slonik": "^40.2.1",
"slonik-utilities": "^2.0.2",
Expand Down
11 changes: 11 additions & 0 deletions tests/drafts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect, describe, it } from "vitest";
import { TEST_SERVER_URL } from "./global.setup";

describe('test suite works', () => {
it("should return all proposals", async () => {
const res = await fetch(TEST_SERVER_URL);
const data = await res.json();
expect(res.status).toEqual(200);
// expect(data).toEqual({ message: "Paginated list of proposals" });
});
})
5 changes: 4 additions & 1 deletion tests/global.setup.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'dotenv/config'
import { createServer } from "http";
import app from "../app";
let server;

export const TEST_SERVER_URL = `${process.env.TEST_SERVER_HOST}:${process.env.TEST_SERVER_PORT}`

export async function setup() {
server = createServer(app);
server.listen(3000);
server.listen(process.env.TEST_SERVER_PORT);
}

export async function teardown() {
Expand Down
19 changes: 0 additions & 19 deletions tests/topics.test.js

This file was deleted.

0 comments on commit 8f6100e

Please sign in to comment.