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

Set up testing environment and coverage integration #25

Merged
merged 20 commits into from
Aug 15, 2024

Conversation

mitsuki31
Copy link
Owner

@mitsuki31 mitsuki31 commented Aug 15, 2024

Overview

This pull request introduces several significant updates to set up the testing infrastructure and enhance code quality for the project. The changes include the addition of new testing dependencies, the creation of initial unit and integration tests, updates to ESLint configurations, and the inclusion of various npm scripts.

Notable Changes

  • Added mocha as the test runner to facilitate running and managing tests.

  • Added nyc (Istanbul) for code coverage collection to ensure comprehensive test coverage reporting.

  • Added unit tests in the following files:

    • audioconv.spec.mjs
    • config.spec.mjs
    • utils.spec.mjs
    • yt-urlfmt.spec.mjs
  • Implemented an initial integration test to validate end-to-end functionality, this also include batch download test to validate bulk processing capabilities.

  • Added eslint-plugin-mocha as a dev-dependency to integrate Mocha testing framework with ESLint.

  • Updated main ESLint configuration to:

    • Precisely ignore specified files.
    • Integrate with the Mocha plugin for test environment settings.
    • Set reportUnusedDisableDirectives to true to improve directive management.
  • Removed the global module:readonly configuration from the JSDoc config file.

  • Added ESLint configuration for the test environment to accommodate the new test dependencies and ensure consistency in code quality.

  • Added nycrc.json to configure nyc (Istanbul) for code coverage thresholds.

  • Added several new npm scripts to streamline development and testing processes.

  • Enhanced utils tests by adding a line break and resolving path issues.

  • Added several npm scripts for testing environment.

    Name Command
    lint npm run lint:prod && npm run lint:test
    lint:prod eslint . -c eslint.config.js
    lint:test eslint . -c eslint.config.test.js
    test npm run test:unit && npm run test:irl
    test:nyan mocha --recursive --reporter nyan
    test:unit mocha test/unittest
    test:nyan:unit mocha test/unittest --reporter nyan
    test:irl mocha test/irl.test.js
    coverage nyc --reporter lcov --reporter text npm test

Impact

These changes will provide a more robust testing framework, improve code coverage insights, and enforce higher code quality standards. The new configurations and scripts will also enhance development efficiency and maintainability.

Future Work

We will continuously monitor and update code coverage thresholds as possible as we can.

Testing

  • Run npm test to execute the unit and integration tests.
  • Run npm run coverage to check code coverage reports generated by nyc for test completeness.

* Added `mocha` as test runner
* Added `nyc` (Istanbul) as code coverage collector
* Added `audioconv.spec.mjs`
* Added `config.spec.mjs`
* Added `utils.spec.mjs`
* Added `yt-urlfmt.spec.mjs`
Added as dev-dependency for ESLint config.
* Resolved the `ignores` field to exactly ignore specfied files
* Integrate with mocha plugin for testing
* Changed the value of 'reportUnusedDisableDirectives' to 'true' (boolean)
* Removed the 'global module:readonly' in JSDoc config file
* Added test suite for `utils.createDirIfNotExistSync` function
* Added test suite for `utils.logger` object along with its methods
* Added a new test suite which test the `checkFfmpeg` function to rejects if FFMPEG_PATH environment variable is set to a directory
@mitsuki31 mitsuki31 added the chore Maintenance updates to improve project maintainability label Aug 15, 2024
@mitsuki31 mitsuki31 self-assigned this Aug 15, 2024
@mitsuki31 mitsuki31 force-pushed the test/add-test-suites branch from be2bf17 to 17125ef Compare August 15, 2024 10:34
* Changed the array reversion method to use ES6 supported instead
* Added double checker to check ffmpeg binary
Due to the `ReadableStream` was released stable on Node.js version 18
@mitsuki31 mitsuki31 marked this pull request as draft August 15, 2024 11:22
* Improved status checker of child process that calls ffmpeg and prevent return `true` if null or undefined
* Disabled the verbose option in `checkFfmpeg` test to avoid confusion when `ffmpeg` is not installed on system
@mitsuki31
Copy link
Owner Author

mitsuki31 commented Aug 15, 2024

Due to YouTube bot detection when downloading YouTube videos, the "IRL Test" workflow will not be triggered automatically until we address it.

As far as I did tests on my local machine, the IRL tests did not throw an error with message "Sign in to confirm you're not a bot.".

If want to run the test, type command npm run test:irl.

@mitsuki31 mitsuki31 marked this pull request as ready for review August 15, 2024 12:10
@mitsuki31 mitsuki31 merged commit 98fe13c into master Aug 15, 2024
9 checks passed
@mitsuki31 mitsuki31 deleted the test/add-test-suites branch August 15, 2024 12:29
@mitsuki31 mitsuki31 added the minor Minor changes label Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Maintenance updates to improve project maintainability minor Minor changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant