Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const config: Config = {
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.ts'],
testEnvironment: 'node',
testRegex: ['.*\\.test\\.ts$'],
// Tell Jest to ignore the specific duplicate package.json files
// that are causing Haste module naming collisions
modulePathIgnorePatterns: [
'<rootDir>/test/e2e/prompt-module/data/'
],
transformIgnorePatterns: [
'node_modules/(?!(cli-testing-library|@clack|cleye)/.*)'
],
Expand All @@ -29,10 +34,6 @@ const config: Config = {
}
]
},
// Fix Haste module naming collision
modulePathIgnorePatterns: [
'<rootDir>/test/e2e/prompt-module/data/'
],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1'
}
Expand Down
32 changes: 29 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ollama:start": "OCO_AI_PROVIDER='ollama' node ./out/cli.cjs",
"dev": "ts-node ./src/cli.ts",
"dev:gemini": "OCO_AI_PROVIDER='gemini' ts-node ./src/cli.ts",
"build": "rimraf out && node esbuild.config.js",
"build": "npx rimraf out && node esbuild.config.js",
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
"deploy": "npm publish --tag latest",
"deploy:build": "npm run build:push && git push --tags && npm run deploy",
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/gitPush.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('cli flow to push git branch', () => {
await render('git', ['add index.ts'], { cwd: gitDir });

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

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

const { findByText, userEvent } = await render(
`OCO_AI_PROVIDER='test' node`,
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
[resolve('./out/cli.cjs')],
{ cwd: gitDir }
);
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/oneFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ it('cli flow to generate commit message for 1 new file (staged)', async () => {
await render('echo' ,[`'console.log("Hello World");' > index.ts`], { cwd: gitDir });
await render('git' ,['add index.ts'], { cwd: gitDir });

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

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

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

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

expect(await findByText('No files are staged')).toBeInTheConsole();
expect(await findByText('Do you want to stage all files and generate commit message?')).toBeInTheConsole();
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/prompt-module/commitlint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { prepareEnvironment, wait } from '../utils';
import path from 'path';

function getAbsolutePath(relativePath: string) {
const scriptDir = path.dirname(__filename);
return path.resolve(scriptDir, relativePath);
// Use process.cwd() which should be the project root during test execution
return path.resolve(process.cwd(), 'test/e2e/prompt-module', relativePath);
}
async function setupCommitlint(dir: string, ver: 9 | 18 | 19) {
let packagePath, packageJsonPath, configPath;
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('cli flow to run "oco commitlint force"', () => {
`
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
OCO_PROMPT_MODULE='@commitlint' \
OCO_AI_PROVIDER='test' \
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
node ${resolve('./out/cli.cjs')} commitlint force \
`,
[],
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('cli flow to run "oco commitlint force"', () => {
`
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
OCO_PROMPT_MODULE='@commitlint' \
OCO_AI_PROVIDER='test' \
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
node ${resolve('./out/cli.cjs')} commitlint force \
`,
[],
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('cli flow to run "oco commitlint force"', () => {
`
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
OCO_PROMPT_MODULE='@commitlint' \
OCO_AI_PROVIDER='test' \
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
node ${resolve('./out/cli.cjs')} commitlint force \
`,
[],
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
`
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
OCO_PROMPT_MODULE='@commitlint' \
OCO_AI_PROVIDER='test' \
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
node ${resolve('./out/cli.cjs')} commitlint force \
`,
[],
Expand All @@ -175,7 +175,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
`
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
OCO_PROMPT_MODULE='@commitlint' \
OCO_AI_PROVIDER='test' \
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
node ${resolve('./out/cli.cjs')} commitlint get \
`,
[],
Expand All @@ -193,7 +193,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
`
OCO_TEST_MOCK_TYPE='commit-message' \
OCO_PROMPT_MODULE='@commitlint' \
OCO_AI_PROVIDER='test' \
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
node ${resolve('./out/cli.cjs')} \
`,
[],
Expand Down
1 change: 1 addition & 0 deletions test/jest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { jest } from '@jest/globals';
import 'cli-testing-library/extend-expect';
import { configure } from 'cli-testing-library';

// Make Jest available globally
global.jest = jest;

/**
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"target": "ES2020",
"lib": ["ES6", "ES2020"],

"module": "CommonJS",
"module": "NodeNext",

"resolveJsonModule": true,
"moduleResolution": "Node",
"moduleResolution": "NodeNext",

"allowJs": true,

Expand Down