Skip to content

Commit bc514f8

Browse files
authored
Merge pull request #461 from kaovilai/dep-updates
fix tests
2 parents f6de2dc + 3b868ce commit bc514f8

File tree

8 files changed

+51
-23
lines changed

8 files changed

+51
-23
lines changed

jest.config.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const config: Config = {
1313
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.ts'],
1414
testEnvironment: 'node',
1515
testRegex: ['.*\\.test\\.ts$'],
16+
// Tell Jest to ignore the specific duplicate package.json files
17+
// that are causing Haste module naming collisions
18+
modulePathIgnorePatterns: [
19+
'<rootDir>/test/e2e/prompt-module/data/'
20+
],
1621
transformIgnorePatterns: [
1722
'node_modules/(?!(cli-testing-library|@clack|cleye)/.*)'
1823
],
@@ -29,10 +34,6 @@ const config: Config = {
2934
}
3035
]
3136
},
32-
// Fix Haste module naming collision
33-
modulePathIgnorePatterns: [
34-
'<rootDir>/test/e2e/prompt-module/data/'
35-
],
3637
moduleNameMapper: {
3738
'^(\\.{1,2}/.*)\\.js$': '$1'
3839
}

package-lock.json

Lines changed: 29 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"ollama:start": "OCO_AI_PROVIDER='ollama' node ./out/cli.cjs",
4545
"dev": "ts-node ./src/cli.ts",
4646
"dev:gemini": "OCO_AI_PROVIDER='gemini' ts-node ./src/cli.ts",
47-
"build": "rimraf out && node esbuild.config.js",
47+
"build": "npx rimraf out && node esbuild.config.js",
4848
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
4949
"deploy": "npm publish --tag latest",
5050
"deploy:build": "npm run build:push && git push --tags && npm run deploy",

test/e2e/gitPush.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('cli flow to push git branch', () => {
125125
await render('git', ['add index.ts'], { cwd: gitDir });
126126

127127
const { queryByText, findByText, userEvent } = await render(
128-
`OCO_AI_PROVIDER='test' node`,
128+
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
129129
[resolve('./out/cli.cjs')],
130130
{ cwd: gitDir }
131131
);
@@ -158,7 +158,7 @@ describe('cli flow to push git branch', () => {
158158
await render('git', ['add index.ts'], { cwd: gitDir });
159159

160160
const { findByText, userEvent } = await render(
161-
`OCO_AI_PROVIDER='test' node`,
161+
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
162162
[resolve('./out/cli.cjs')],
163163
{ cwd: gitDir }
164164
);
@@ -186,7 +186,7 @@ describe('cli flow to push git branch', () => {
186186
await render('git', ['add index.ts'], { cwd: gitDir });
187187

188188
const { findByText, userEvent } = await render(
189-
`OCO_AI_PROVIDER='test' node`,
189+
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
190190
[resolve('./out/cli.cjs')],
191191
{ cwd: gitDir }
192192
);

test/e2e/oneFile.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ it('cli flow to generate commit message for 1 new file (staged)', async () => {
99
await render('echo' ,[`'console.log("Hello World");' > index.ts`], { cwd: gitDir });
1010
await render('git' ,['add index.ts'], { cwd: gitDir });
1111

12-
const { queryByText, findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
12+
const { queryByText, findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
1313
expect(await queryByText('No files are staged')).not.toBeInTheConsole();
1414
expect(await queryByText('Do you want to stage all files and generate commit message?')).not.toBeInTheConsole();
1515

@@ -34,7 +34,7 @@ it('cli flow to generate commit message for 1 changed file (not staged)', async
3434

3535
await render('echo' ,[`'console.log("Good night World");' >> index.ts`], { cwd: gitDir });
3636

37-
const { findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
37+
const { findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
3838

3939
expect(await findByText('No files are staged')).toBeInTheConsole();
4040
expect(await findByText('Do you want to stage all files and generate commit message?')).toBeInTheConsole();

test/e2e/prompt-module/commitlint.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { prepareEnvironment, wait } from '../utils';
55
import path from 'path';
66

77
function getAbsolutePath(relativePath: string) {
8-
const scriptDir = path.dirname(__filename);
9-
return path.resolve(scriptDir, relativePath);
8+
// Use process.cwd() which should be the project root during test execution
9+
return path.resolve(process.cwd(), 'test/e2e/prompt-module', relativePath);
1010
}
1111
async function setupCommitlint(dir: string, ver: 9 | 18 | 19) {
1212
let packagePath, packageJsonPath, configPath;
@@ -47,7 +47,7 @@ describe('cli flow to run "oco commitlint force"', () => {
4747
`
4848
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
4949
OCO_PROMPT_MODULE='@commitlint' \
50-
OCO_AI_PROVIDER='test' \
50+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
5151
node ${resolve('./out/cli.cjs')} commitlint force \
5252
`,
5353
[],
@@ -83,7 +83,7 @@ describe('cli flow to run "oco commitlint force"', () => {
8383
`
8484
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
8585
OCO_PROMPT_MODULE='@commitlint' \
86-
OCO_AI_PROVIDER='test' \
86+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
8787
node ${resolve('./out/cli.cjs')} commitlint force \
8888
`,
8989
[],
@@ -119,7 +119,7 @@ describe('cli flow to run "oco commitlint force"', () => {
119119
`
120120
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
121121
OCO_PROMPT_MODULE='@commitlint' \
122-
OCO_AI_PROVIDER='test' \
122+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
123123
node ${resolve('./out/cli.cjs')} commitlint force \
124124
`,
125125
[],
@@ -160,7 +160,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
160160
`
161161
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
162162
OCO_PROMPT_MODULE='@commitlint' \
163-
OCO_AI_PROVIDER='test' \
163+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
164164
node ${resolve('./out/cli.cjs')} commitlint force \
165165
`,
166166
[],
@@ -175,7 +175,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
175175
`
176176
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
177177
OCO_PROMPT_MODULE='@commitlint' \
178-
OCO_AI_PROVIDER='test' \
178+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
179179
node ${resolve('./out/cli.cjs')} commitlint get \
180180
`,
181181
[],
@@ -193,7 +193,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
193193
`
194194
OCO_TEST_MOCK_TYPE='commit-message' \
195195
OCO_PROMPT_MODULE='@commitlint' \
196-
OCO_AI_PROVIDER='test' \
196+
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
197197
node ${resolve('./out/cli.cjs')} \
198198
`,
199199
[],

test/jest-setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { jest } from '@jest/globals';
22
import 'cli-testing-library/extend-expect';
33
import { configure } from 'cli-testing-library';
44

5+
// Make Jest available globally
56
global.jest = jest;
67

78
/**

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"target": "ES2020",
44
"lib": ["ES6", "ES2020"],
55

6-
"module": "CommonJS",
6+
"module": "NodeNext",
77

88
"resolveJsonModule": true,
9-
"moduleResolution": "Node",
9+
"moduleResolution": "NodeNext",
1010

1111
"allowJs": true,
1212

0 commit comments

Comments
 (0)