Skip to content

[테스트] Jest 테스트 세팅 추가#18

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-17
Draft

[테스트] Jest 테스트 세팅 추가#18
Copilot wants to merge 2 commits intomainfrom
copilot/fix-17

Conversation

Copy link
Copy Markdown

Copilot AI commented Sep 22, 2025

This PR adds a comprehensive Jest testing setup to the ClipBE-Express project, enabling developers to write and run tests for the Express.js application with full ES modules support.

What's Added

Jest Configuration

  • Jest with ES modules support using NODE_OPTIONS='--experimental-vm-modules'
  • Clean jest.config.js configuration optimized for Node.js environment
  • Proper test file patterns and coverage collection settings

Test Scripts

Added three new npm scripts for different testing scenarios:

npm test              # Run all tests once
npm run test:watch    # Run tests in watch mode for development
npm run test:coverage # Generate coverage reports

Test Structure

Created organized test directory structure:

__tests__/
├── utils/
│   ├── responseFormatter.test.js
│   └── errors.test.js
└── apis/clip/service/
    └── getAllClips.test.js

Example Tests

  • Utility function tests: Comprehensive tests for responseFormatter and CustomError classes with 100% coverage
  • Service layer tests: Demonstrates mocking capabilities with the getAllClips service, showing how to mock repository dependencies
  • 14 tests total covering various scenarios including edge cases

Development Environment Integration

  • Updated .gitignore to exclude test coverage reports
  • Enhanced ESLint configuration to support Jest globals in test files
  • All tests pass linting with existing code style rules

Testing Example

The setup enables testing patterns like this:

// Testing utilities
import { createSuccessResponse } from '../../src/utils/responseFormatter.js';

test('should create success response with data', () => {
  const result = createSuccessResponse({ message: 'Test' });
  expect(result.status).toBe('SUCCESS');
  expect(result.data.message).toBe('Test');
});

// Testing services with mocks
jest.unstable_mockModule('repository/findAllClips.js', () => ({
  findAllClips: jest.fn()
}));

test('should format clips data correctly', async () => {
  findAllClips.mockResolvedValue(mockData);
  const result = await getAllClips();
  expect(result.status).toBe('SUCCESS');
});

Test Results

✅ All 14 tests passing
✅ 100% coverage on utility functions
✅ Proper mocking capabilities demonstrated
✅ ES modules compatibility confirmed

Fixes #17.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • scarf.sh

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Dobbymin Dobbymin added the 🙏🏻 Test 테스트 코드 관련 작업을 진행하는 경우 label Sep 22, 2025
- Install Jest and related dependencies for ES modules support
- Configure Jest for ES modules in jest.config.js
- Update package.json scripts for testing (test, test:watch, test:coverage)
- Create test directory structure (__tests__)
- Add comprehensive tests for utility functions (responseFormatter, errors)
- Add sample test for service layer (getAllClips with mocked repository)
- Update .gitignore to exclude test coverage reports
- Update ESLint configuration to support Jest globals
Copilot AI changed the title [WIP] [테스트] 테스트 세팅 [테스트] Jest 테스트 세팅 추가 Sep 22, 2025
Copilot AI requested a review from Dobbymin September 22, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙏🏻 Test 테스트 코드 관련 작업을 진행하는 경우

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[테스트] 테스트 세팅

2 participants