Skip to content

Commit dae930a

Browse files
authored
updates to try and run tests (#17)
1 parent 1943806 commit dae930a

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

jest.config.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} **/
2+
module.exports = {
3+
preset: 'ts-jest/presets/default-esm',
4+
testEnvironment: 'node',
5+
testMatch: ['**/src/**/*.test.ts'],
6+
transform: {
7+
"^.+\\.tsx?$": ['ts-jest', {
8+
useESM: true,
9+
tsconfig: 'tsconfig.json',
10+
}],
11+
},
12+
};

jest.config.js

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

src/index.test.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1+
import logger from "./shared/app-logger";
2+
import { runCopilotAssociationsReport } from "./report/copilot-associations-report";
13

2-
// import { getMessage } from './index'
4+
// Mock the logger and report function
5+
jest.mock("./shared/app-logger");
6+
jest.mock("./report/copilot-associations-report");
37

4-
// describe('getMessage()', () => {
5-
// it('should return the correct message when called', () => {
6-
// expect(getMessage()).toBe('Hello world!')
7-
// })
8+
describe("index.ts", () => {
9+
it("should log start and end messages", async () => {
10+
const mockLoggerInfo = logger.info as jest.Mock;
11+
const mockRunReport = runCopilotAssociationsReport as jest.Mock;
812

9-
// it('should be super smart', () => {
10-
// expect(true).toBe(true)
11-
// })
12-
// });
13+
// Mock the report function to resolve with a test file name
14+
mockRunReport.mockResolvedValue("test-output-file.txt");
15+
16+
// Import the index file to trigger the code
17+
await import("./index");
18+
19+
// Check that the start message was logged
20+
expect(mockLoggerInfo).toHaveBeenCalledWith("START - Running copilot associations report...");
21+
22+
// Check that the end message was logged with the correct file name
23+
expect(mockLoggerInfo).toHaveBeenCalledWith("END - Generated copilot associations report test-output-file.txt");
24+
});
25+
});

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"skipLibCheck": true,
88
"strict": true,
99
"outDir": "./dist",
10-
"rootDir": "./src"
10+
"rootDir": "./src",
11+
"resolveJsonModule": true,
12+
"isolatedModules": true
1113
},
1214
"include": ["src/**/*.ts"],
1315
"exclude": ["node_modules"]

0 commit comments

Comments
 (0)