yzhu27/UnitPriceHelper

Add unit test and code coverage

Closed this issue · 3 comments

Unit test and code coverage is required for more stable performance

Added unit tests for functions:

  • addListPriceTips
  • harrisConverter
  • costcoConverter
    GitHub Action is enabled for automatically run unit tests when push.

Current code coverage:

  21 passing (155ms)

-------------------|---------|----------|---------|---------|-----------------------------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                       
-------------------|---------|----------|---------|---------|-----------------------------------------
All files          |   70.92 |    53.96 |   44.44 |    69.4 |                                         
 content_script.js |   70.92 |    53.96 |   44.44 |    69.4 | 57-61,89-95,108-165,172-173,259,266,288 
-------------------|---------|----------|---------|---------|-----------------------------------------

Since some functions requires specific browser environment and domain to operate, it is too difficult to simulate and implement unit tests for them, future enhancement required.

Current code coverage:

-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |   94.89 |    81.66 |   88.88 |   94.81 |                   
 content_script.js |   94.89 |    81.66 |   88.88 |   94.81 | 71-75,103,164     
-------------------|---------|----------|---------|---------|-------------------

Specific Lines is unreachable now, but total coverage meets requirement.