Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to force require() for config files handling #42

Closed

Conversation

mitsuki31
Copy link
Owner

@mitsuki31 mitsuki31 commented Aug 27, 2024

Moved to #43

* Updated `extractVideoId` tests to check various YouTube domains.
* Added validation for URLs converted to URL objects.
* Expanded error checks in `extractVideoId` tests.
* Added tests for `ProgressBar` initialization and formatting.
* Expanded `createLogFile` tests for default and custom prefixes.
* Improved `createDirIfNotExist` and `createDirIfNotExistSync` tests for directory creation and validation.
- Expanded `importConfig` tests to cover JSON, ES Module, and CommonJS formats.
- Added test cases to ensure proper error handling for invalid config file paths and unknown extensions.
- Introduced tests for `parseConfig` to validate both simple and resolved configurations.
- Extended `resolveConfig` tests to verify audio conversion options and handling of nullable values.
- Added `configChecker` tests to enforce type checks and unknown option validation.
- Updated temporary file handling for better isolation and cleanup.
- Added unit tests for `splitOptions`, `writeErrorLog`, and `createConversionProgress` functions.
- Improved coverage for `checkFfmpeg` and `resolveOptions` with more edge case scenarios.
- Refactored `checkFfmpeg` tests to use temporary paths and stubs for `child_process.spawnSync`.
- Added thorough validation for error logging with `writeErrorLog`.
- Ensured robust handling and testing of conversion progress reporting.
- Exported `splitOptions`, `createConversionProgress`, and `writeErrorLog` functions from `audioconv` module for testing use.

Improves overall test coverage and ensures better reliability of the `audioconv` module.
- Introduced new test cases for the `convertAudio` function to ensure robust error handling and correct execution:
  - Test to verify that an error is thrown when the input file does not exist.
  - Test to check rejection when `ffmpeg` is not installed or correctly set up.
  - Test to confirm that `ffmpeg` chain pre-setup passes without errors when valid options are provided.
- Mocked dependencies and environment variables to isolate tests and avoid side effects.

These additions significantly improve the test coverage for critical scenarios within the `convertAudio` function, ensuring greater reliability and stability in the `audioconv` module.
- Refactored tests for better readability and maintainability.
- Added new `describe` blocks for new test cases covering audio conversion and error handling scenarios.
- Implemented stubs for `console.log` and `console.error` to suppress output during tests.
- Improved test cases for file operations and audio conversion validation.
- Improved error handling in the `convertAudio` function by safely retrieving the input file size. This prevents potential crashes if the input file is deleted unexpectedly.
- Enhanced logging of error details, including input file size and better error context.
- Added a `.mocharc.js` configuration file to standardize Mocha test settings.
- Added sample audio file `testaudio-160-pcm_s32le.wav` for testing purposes.
- Enabled `check-coverage` to enforce code coverage thresholds.
- Excluded `.mocharc.js` and temporary files (`tmp/**`) from coverage reporting.
- Added `forceRequire` parameter to `parseConfig` and `importConfig` functions.
- Enabled forcing the use of `require()` for configuration files, regardless of their extension.
- Improved compatibility with Windows by replacing backslashes with forward slashes when using `import()`.
@mitsuki31 mitsuki31 closed this Aug 27, 2024
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 66.02%. Comparing base (8b08c73) to head (8d00d89).

Files Patch % Lines
lib/audioconv.js 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master      #42       +/-   ##
===========================================
+ Coverage   41.78%   66.02%   +24.24%     
===========================================
  Files           7        7               
  Lines         414      418        +4     
===========================================
+ Hits          173      276      +103     
+ Misses        241      142       -99     
Flag Coverage Δ
Ubuntu 65.78% <42.85%> (+24.00%) ⬆️
Windows 66.02% <57.14%> (+24.24%) ⬆️
macOS 65.78% <42.85%> (+24.00%) ⬆️
unittests 66.02% <57.14%> (+24.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mitsuki31 mitsuki31 deleted the feat/add-force-require-option-in-config-handler branch August 27, 2024 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant