Skip to content

Commit ffb00cf

Browse files
committed
2 parents 1564f8d + 9af84f7 commit ffb00cf

13 files changed

Lines changed: 2258 additions & 5068 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Backend Tests
2+
3+
on:
4+
push:
5+
paths:
6+
- "server/**"
7+
pull_request:
8+
paths:
9+
- "server/**"
10+
11+
jobs:
12+
backend-tests:
13+
runs-on: ubuntu-latest
14+
15+
services:
16+
mongodb:
17+
image: mongo:8
18+
ports:
19+
- 27017:27017
20+
21+
options: >-
22+
--health-cmd="mongosh --eval 'db.adminCommand({ ping: 1 })'"
23+
--health-interval=10s
24+
--health-timeout=5s
25+
--health-retries=5
26+
27+
env:
28+
NODE_ENV: test
29+
TEST_DB_URL: mongodb://localhost:27017/test_db
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
35+
- name: Check for Server Changes
36+
id: filter
37+
uses: dorny/paths-filter@v3
38+
with:
39+
filters: |
40+
server:
41+
- "server/**"
42+
43+
- name: Setup Node
44+
if: steps.filter.outputs.server == 'true'
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: 24
48+
cache: npm
49+
cache-dependency-path: server/package-lock.json
50+
51+
- name: Install Server Dependencies
52+
if: steps.filter.outputs.server == 'true'
53+
working-directory: ./server
54+
run: npm ci --legacy-peer-deps
55+
56+
- name: Run Tests
57+
if: steps.filter.outputs.server == 'true'
58+
working-directory: ./server
59+
run: npm test

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[![Linting](https://github.com/Darosss/StreamManager/actions/workflows/linting.yaml/badge.svg)](https://github.com/Darosss/StreamManager/actions/workflows/linting.yaml)
22

3+
[![Backend Tests](https://github.com/Darosss/StreamManager/actions/workflows/backend-tests.yaml/badge.svg)](https://github.com/Darosss/StreamManager/actions/workflows/backend-tests.yaml)
4+
35
# Stream Manager
46

57
<a name="readme-top"></a>

server/babel.config.js

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

server/jest.config.js

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
12
/** @type {import('jest').Config} */
3+
const { pathsToModuleNameMapper } = require("ts-jest");
4+
const { compilerOptions } = require("./tsconfig.json");
5+
module.exports = {
6+
projects: [
7+
{
8+
displayName: "unit",
9+
preset: "ts-jest/presets/default-esm",
210

3-
const config = {
4-
testEnvironment: "node",
5-
transform: {
6-
"^.+\\.(ts|js)$": "babel-jest"
7-
},
8-
transformIgnorePatterns: ["node_modules/(?!(@twurple)/)"],
9-
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
10-
moduleFileExtensions: ["ts", "js", "json"],
11-
clearMocks: true
12-
};
11+
testEnvironment: "node",
12+
transform: {
13+
"^.+\\.(ts|js)$": ["ts-jest", { useESM: true, tsconfig: "tsconfig.json" }]
14+
},
15+
16+
clearMocks: true,
17+
moduleFileExtensions: ["ts", "js", "json"],
18+
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
19+
testMatch: ["**/unit/*.test.ts"],
20+
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
21+
prefix: "<rootDir>/"
22+
}),
23+
setupFilesAfterEnv: ["<rootDir>/tests/mock.setup.js"]
24+
},
25+
{
26+
displayName: "integration",
27+
preset: "ts-jest/presets/default-esm",
1328

14-
module.exports = config;
29+
testEnvironment: "node",
30+
transform: {
31+
"^.+\\.(ts|js)$": ["ts-jest", { useESM: true, tsconfig: "tsconfig.json" }]
32+
},
33+
34+
clearMocks: true,
35+
moduleFileExtensions: ["ts", "js", "json"],
36+
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
37+
testMatch: ["**/integration/*.test.ts"],
38+
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
39+
prefix: "<rootDir>/"
40+
}),
41+
setupFilesAfterEnv: ["<rootDir>/tests/mock.setup.js"]
42+
}
43+
]
44+
};

0 commit comments

Comments
 (0)