Skip to content

Commit e35948c

Browse files
author
Matthew Wolff
committed
hardcoding test import paths for yarn test
1 parent 351d102 commit e35948c

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

.github/workflows/yarn.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ jobs:
2020
uses: borales/actions-yarn@v5
2121
with:
2222
cmd: test # will run `yarn test` command
23+
env:
24+
GITHUB_TEST: true

__tests__/interactionHandler.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ describe('InteractionHandler', () => {
5151
}
5252
} as unknown as Client;
5353

54-
const { InteractionHandler: RealHandler } = jest.requireActual('@/handler/interactionHandler');
54+
const { InteractionHandler: RealHandler } = jest.requireActual(
55+
`${process.env.GITHUB_TEST ? 'src' : '../src'}/handler/interactionHandler`
56+
);
5557
handler = new RealHandler(mockClient);
5658
});
5759

__tests__/presenceUpdateHandler.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import { PresenceUpdateHandler } from '../src/handler';
22
import { Client, Message, Presence, User } from 'discord.js';
33
import { ActivityType } from 'discord-api-types/v10';
44
import { GameDatabase } from '../src/model';
5+
import { getLogger } from "../src/util";
56

67
jest.mock('discord.js');
7-
jest.mock('@/model/gameDatabase');
8+
const logger = getLogger("testing")
9+
logger.error("CURRENT DIR: " + process.cwd());
10+
jest.mock(`${process.env.GITHUB_TEST ? 'src' : '../src'}/model/gameDatabase`);
811

912
const mockMessage = { content: 'Test message' } as Message;
1013
const mockSend = jest.fn().mockResolvedValue(mockMessage);

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
"jest": {
1616
"preset": "ts-jest",
1717
"testEnvironment": "node",
18-
"moduleDirectories": ["node_modules", "src"],
19-
"moduleNameMapper": {
20-
"^@/(.*)$": "<rootDir>/src/$1"
21-
},
2218
"moduleFileExtensions": [
2319
"ts",
2420
"js",

src/model/gameDatabase.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import * as fs from 'fs/promises';
22
import { getLogger } from '../util';
3+
import * as file from 'fs';
4+
35
import { User } from "discord.js";
6+
import path from "node:path";
47

58
const logger = getLogger('model.gameDatabase');
69

@@ -59,6 +62,17 @@ export class GameDatabase {
5962
* Finds a user by their Discord ID
6063
*/
6164
findUserByID(userId: string): UserData | undefined {
65+
const cwd = process.cwd();
66+
const entries = file.readdirSync(cwd);
67+
68+
// Print all entries
69+
logger.error('\nDirectory contents:');
70+
entries.forEach(entry => {
71+
const fullPath = path.join(cwd, entry);
72+
const stats = file.statSync(fullPath);
73+
logger.error(`${entry} (${stats.isDirectory() ? 'directory' : 'file'})`);
74+
});
75+
6276
const userEntry = Object.entries(this.data.users)
6377
.find(([_, userData]) => userData.userId === userId);
6478
return userEntry ? userEntry[1] : undefined;

tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"compilerOptions": {
3-
"baseUrl": ".",
4-
"paths": { "@/*": ["src/*"] },
53
"experimentalDecorators": true, // Enable experimental support for TypeScript decorators
64
"skipLibCheck": true, // Skip type checking of declaration files (*.d.ts)
75
"target": "es6", // Specify the ECMAScript target version (ES6 in this case)

0 commit comments

Comments
 (0)