Only run unit tests on CI

This commit is contained in:
Alexander Ungar 2023-04-04 11:55:49 +02:00
parent badaed630b
commit 384bc051a1
7 changed files with 55 additions and 30 deletions

View file

@ -25,8 +25,8 @@ jobs:
- name: Build application
run: yarn build
- name: Run tests
run: yarn test
- name: Run unit tests
run: yarn test:unit
cloud_build:
needs: build_and_test

View file

@ -0,0 +1,9 @@
import baseConfig from "./jest.config"
import { type Config } from "jest";
const config: Config = {
...baseConfig,
testRegex: ".*\\.integration\\.spec\\.ts$",
}
export default config;

24
jest.config.ts Normal file
View file

@ -0,0 +1,24 @@
import { type Config } from "jest";
const config: Config = {
moduleFileExtensions: [
"js",
"json",
"ts"
],
rootDir: ".",
transform: {
"^.+\\.(t|j)s$": "ts-jest"
},
testEnvironment: "node",
roots: [
"<rootDir>/src/"
],
moduleDirectories: [
"node_modules",
"src"
],
setupFiles: ["./src/preStart.ts"]
}
export default config;

9
jest.config.unit.ts Normal file
View file

@ -0,0 +1,9 @@
import baseConfig from "./jest.config"
import { type Config } from "jest";
const config: Config = {
...baseConfig,
testRegex: ".*\\.unit\\.spec\\.ts$",
}
export default config;

View file

@ -13,7 +13,8 @@
"build": "run-s clean generate-api-types compile copy-resources",
"lint": "eslint --ext .ts src/",
"dev": "nodemon src/server.ts",
"test": "jest"
"test:unit": "jest --config \"jest.config.unit.ts\"",
"test:integration": "jest --config \"jest.config.integration.ts\""
},
"dependencies": {
"@types/supertest": "^2.0.12",
@ -60,26 +61,5 @@
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.2",
"typescript": "^5.0.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": ".",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"testEnvironment": "node",
"roots": [
"<rootDir>/src/"
],
"moduleDirectories": [
"node_modules",
"src"
],
"setupFiles": ["./src/preStart.ts"]
}
}

View file

@ -19,13 +19,16 @@ interface Args {
// **** Setup **** //
// Command line arguments
const args = parse<Args>({
env: {
type: String,
defaultValue: process.env.NODE_ENV ?? "development",
alias: "e",
const args = parse<Args>(
{
env: {
type: String,
defaultValue: process.env.NODE_ENV ?? "development",
alias: "e",
},
},
});
{ partial: true }
);
// Set the env file
const dotenvConfig = dotenv.config({