Joedahms / Software-Engineering-Project

1 stars 2 forks source link

Test Suite debug issues #84

Closed geromyc closed 1 month ago

geromyc commented 1 month ago

PS C:\Users\Geromy\OneDrive\Documents\VS_Code\ECE461\Software-Engineering-Project> pnpm test

@ test C:\Users\Geromy\OneDrive\Documents\VS_Code\ECE461\Software-Engineering-Project jest

FAIL test/repository.test.ts ● Test suite failed to run

Cannot find module '../src/metric.js' from 'test/repository.test.ts'                                                                                                                                                                                                                                                                         

  4 | import { RepoStats } from '../src/api_access.js';                                                                                                                                                                                                                                                                                      
  5 |                                                                                                                                                                                                                                                                                                                                        
> 6 | jest.mock('../src/metric.js');                                                                                                                                                                                                                                                                                                         
    |      ^                                                                                                                                                                                                                                                                                                                                 
  7 | jest.mock('../src/api_access.js');                                                                                                                                                                                                                                                                                                     
  8 |                                                                                                                                                                                                                                                                                                                                        
  9 | describe('Repository', () => {                                                                                                                                                                                                                                                                                                         

  at Resolver._throwModNotFoundError (node_modules/.pnpm/jest-resolve@29.7.0/node_modules/jest-resolve/build/resolver.js:427:11)                                                                                                                                                                                                             
  at Object.<anonymous> (test/repository.test.ts:6:6)

PASS test/logger.test.ts PASS test/output.test.ts
FAIL test/api_access.test.ts ● Test suite failed to run

Cannot find module '../node_modules/@octokit/rest' from 'test/api_access.test.ts'                                                                                                                                                                                                                                                            

  1 | import { describe, it, expect, jest, test, beforeEach, afterEach } from '@jest/globals';                                                                                                                                                                                                                                               
> 2 | import { Octokit } from '../node_modules/@octokit/rest';                                                                                                                                                                                                                                                                               
    | ^                                                                                                                                                                                                                                                                                                                                      
  3 | import { fetchCommitCount, checkLicense, RepoStats } from '../src/api_access';                                                                                                                                                                                                                                                         
  4 | import { Logger } from '../src/logger';                                                                                                                                                                                                                                                                                                
  5 |                                                                                                                                                                                                                                                                                                                                        

  at Resolver._throwModNotFoundError (node_modules/.pnpm/jest-resolve@29.7.0/node_modules/jest-resolve/build/resolver.js:427:11)                                                                                                                                                                                                             
  at Object.<anonymous> (test/api_access.test.ts:2:1)

FAIL test/urlFileParser.test.ts ● Test suite failed to run

Cannot find module '../src/logger.js' from 'test/urlFileParser.test.ts'

   8 | jest.mock('node:fs');
   9 | jest.mock('cheerio');
> 10 | jest.mock('../src/logger.js');
     |      ^
  11 | jest.mock('../src/output.js');
  12 |                                                                                                                                                                                                                                                                                                                                       
  13 | describe('UrlFileParser', () => {                                                                                                                                                                                                                                                                                                     

  at Resolver._throwModNotFoundError (node_modules/.pnpm/jest-resolve@29.7.0/node_modules/jest-resolve/build/resolver.js:427:11)
  at Object.<anonymous> (test/urlFileParser.test.ts:10:6)

FAIL test/metric.test.ts ● Test suite failed to run

test/metric.test.ts:27:35 - error TS2345: Argument of type '{ value: number; }' is not assignable to parameter of type 'RampUp'.                                                                                                                                                                                                             
  Type '{ value: number; }' is missing the following properties from type 'RampUp': calculateValue, logger, repoName, repoOwner, and 3 more.                                                                                                                                                                                                 

27     await netScore.calculateValue(rampUp, busFactor, responsiveMaintainer, license);                                                                                                                                                                                                                                                      
                                     ~~~~~~                                                                                                                                                                                                                                                                                                  

FAIL test/main.test.ts ● Test suite failed to run

test/main.test.ts:14:10 - error TS2540: Cannot assign to 'urlFileParser' because it is a read-only property.                                                                                                                                                                                                                                 

14     main.urlFileParser = mockUrlFileParser;                                                                                                                                                                                                                                                                                               
            ~~~~~~~~~~~~~                                                                                                                                                                                                                                                                                                                    
------------------ --------- ---------- --------- --------- ------------------- File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 4.95 46.15 50 4.95
api_access.ts 0 0 0 0 1-292
logger.ts 87.87 71.42 100 87.87 21-22,30-31
main.ts 0 0 0 0 1-58
metric.ts 0 0 0 0 1-233
output.ts 100 100 100 100
repository.ts 0 0 0 0 1-72
urlFileParser.ts 0 0 0 0 1-146
------------------ --------- ---------- --------- --------- -------------------

Test Suites: 5 failed, 2 passed, 7 total Tests: 5 passed, 5 total Snapshots: 0 total Time: 5.367 s Ran all test suites.

geromyc commented 1 month ago

api_access - Need to figure out and add a mock octokit. main - Cannot assign urlFileParser because it is a read-only property. (Likely another mock issue) metric - Type 'Logger' is not assignable to type 'MockedObject'. repository - Issue when it goes to run test that it attempts to run actual script and import variables from metric.js through repository.ts. Needs a mock of class for Url, NetScore, RampUp, Correctness, BusFactor, ResponsiveMaintainer and License. urlFileParser - Tries to load Logger variable similar to above.

geromyc commented 1 month ago

Image

Updating for documentation later. This is what Jonah sent in Discord last night for progress. He got urlFileParser.ts passing the test, but with one caveat. The change he needed to make in the main code broke it. He encountered the same issue as me earlier in the week; the calls in the source files requiring the .js extension when importing at the top of their files. The only known easy fix was to remove the .js and break the main code.

Image

As of this morning I seem to have found a way around the .js issue, still needs further testing, but I also got repository passing with all 100%!

Will update at end of day after I have done some more work.