Skip to content

Implementation of file-specific unit testing capabilities#8

Merged
kakasoo merged 13 commits intokakasoo:mainfrom
luke0408:feat/test-argument-parser
Jan 31, 2025
Merged

Implementation of file-specific unit testing capabilities#8
kakasoo merged 13 commits intokakasoo:mainfrom
luke0408:feat/test-argument-parser

Conversation

@luke0408
Copy link
Contributor

PR Desciption

Now we can choose the code to test by giving an option.

What is changed in code

  1. implementation of an ArgumentParser
  2. implementation of an TestFileLoader
  3. modifying test code execution logic

How to use

[ options ]

  • --include : include feature files
  • --exclude : exclude feature files

[ Ex.1) test with include option ]

$ npm run test -- --include types/DeepDateToString.js

> @kakasoo/deep-strict-types@2.0.1 test
> node bin/test/index.js --include types/DeepDateToString.js

✔ If the prop type of an object is string | Date (2.016012ms)
✔ If the prop type of an object is number | Date (0.243948ms)
✔ If the prop type of an object is undefined | Date (0.227556ms)
✔ If the prop type of an object is null | Date (0.287655ms)
✔ If the prop type of an object is symbol | Date (0.249272ms)
✔ If the prop type of an object is symbol | (string & {}) | Date (0.301142ms)
ℹ tests 6
ℹ suites 0
ℹ pass 6
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 14.44903

[ Ex.2) test with exclude option ]

$ npm run test -- --exclude types/Equal.js

> @kakasoo/deep-strict-types@2.0.1 test
> node bin/test/index.js --exclude types/Equal.js

▶ [function] Definition of `deepStrictObjectKeys` function
  ✔ just empty object (9.349953ms)
  ✔ just empty array (3.106436ms)
  ✔ just empty readonly array (0.913981ms)
  ✔ array in object with `as const` (1.49856ms)
  ✔ <anonymous> (0.598059ms)
  ✔ <anonymous> (1.591498ms)
 
 ... // test all code without test/types/Equal.js file
 
✔ a key in a two-dimensional array (0.18504ms)
ℹ tests 140
ℹ suites 24
ℹ pass 140
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 198.602759

@luke0408
Copy link
Contributor Author

I tried to refine the structure as much as possible, but for TestFileLoader, since there is a possibility of adding various options such as "filtering based on package" or "filtering based on test function" in the future, I placed the related functions as nested functions within the parent function for the convenience of future refactoring.

Copy link
Owner

@kakasoo kakasoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the possibility that __dirname could cause unexpected problems. Other than that, it doesn't seem to matter if it's reflected. Please correct it and I'll merge it.

@kakasoo kakasoo added enhancement New feature or request good first issue Good for newcomers labels Jan 30, 2025
@kakasoo
Copy link
Owner

kakasoo commented Jan 30, 2025

Related to #7

Copy link
Owner

@kakasoo kakasoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.

@kakasoo kakasoo merged commit e041a07 into kakasoo:main Jan 31, 2025
@luke0408
Copy link
Contributor Author

close #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants