fix(tests): improve comments test stability and CI compatibility
- Use delete for Python env vars instead of empty string assignment - Make integration tests opt-in via RUN_INTEGRATION_TESTS=1 env var - Fix regex null coalescing for author matching in tests
This commit is contained in:
parent
2e2888cccc
commit
bbda4d2857
@ -20,6 +20,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Add Claude Code settings (.claude/, CLAUDE.md) to .gitignore
|
||||
- Add development guideline to always update CHANGELOG.md
|
||||
- Move integration test scripts to `tests/` directory for cleaner root
|
||||
- Comments integration tests are now opt-in via `RUN_INTEGRATION_TESTS=1` env var for CI stability
|
||||
|
||||
### Fixed
|
||||
- Fixed comments test Python environment handling (use `delete` instead of empty string assignment)
|
||||
- Fixed regex null coalescing in comments test for author matching
|
||||
|
||||
---
|
||||
|
||||
|
||||
@ -5,11 +5,14 @@ import { getVideoComments, getVideoCommentsSummary } from '../modules/comments.j
|
||||
import type { CommentsResponse } from '../modules/comments.js';
|
||||
import { CONFIG } from '../config.js';
|
||||
|
||||
// Set Python environment
|
||||
process.env.PYTHONPATH = '';
|
||||
process.env.PYTHONHOME = '';
|
||||
// Clear Python environment to avoid yt-dlp issues
|
||||
delete process.env.PYTHONPATH;
|
||||
delete process.env.PYTHONHOME;
|
||||
|
||||
describe('Video Comments Extraction', () => {
|
||||
// Integration tests require network access - opt-in via RUN_INTEGRATION_TESTS=1
|
||||
const RUN_INTEGRATION = process.env.RUN_INTEGRATION_TESTS === '1';
|
||||
|
||||
(RUN_INTEGRATION ? describe : describe.skip)('Video Comments Extraction', () => {
|
||||
// Using a popular video that should have comments enabled
|
||||
const testUrl = 'https://www.youtube.com/watch?v=jNQXAC9IVRw';
|
||||
|
||||
@ -93,10 +96,8 @@ describe('Video Comments Extraction', () => {
|
||||
const summary = await getVideoCommentsSummary(testUrl, 3, CONFIG);
|
||||
|
||||
// Count occurrences of "Author:" to verify number of comments
|
||||
const authorMatches = summary.match(/Author:/g);
|
||||
if (authorMatches) {
|
||||
expect(authorMatches.length).toBeLessThanOrEqual(3);
|
||||
}
|
||||
const authorMatches = summary.match(/Author:/g) ?? [];
|
||||
expect(authorMatches.length).toBeLessThanOrEqual(3);
|
||||
}, 60000);
|
||||
|
||||
test('should throw error for invalid URL', async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user