FCCColumbus / cbus-web

FreeCodeCamp Columbus Website (started in 2022)
BSD 3-Clause "New" or "Revised" License
6 stars 7 forks source link

Implement Code Coverage #15

Open readysetagile opened 2 years ago

readysetagile commented 2 years ago

Attempt to implement Code coverage that is automatically run on CI builds

Acceptance Criteria

GIVEN I am a Free Code Camp developer WHEN I run npm run test on the CLI THEN the coverage folder will be created AND all the unit tests will be run AND I will see the code coverage report

Guidance

readysetagile commented 1 year ago

so simply changing the test line in the scripts section of the package.json file should be enough:

    "test": "react-scripts test --watchAll=false --coverage",

I would like to get our code coverage back in the 'green':

--
I was able to see a code coverage report from a windows command line.  

C:\repos\cbus-web>set CI=true && npm test -- --env=jsdom --coverage

> cbus-web@0.1.0 test
> react-scripts test --coverage --env=jsdom --coverage

 PASS  src/test/components/Members.test.js
 PASS  src/test/components/Event.test.js
 PASS  src/test/components/Header.test.js
 PASS  src/test/components/Footer.test.js
 PASS  src/test/App.test.js
 PASS  src/test/components/Events.test.js
 PASS  src/test/components/Splash.test.js
 PASS  src/test/components/About.test.js
---------------------|---------|----------|---------|---------|-------------------
File                 | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------------|---------|----------|---------|---------|-------------------
All files            |   60.71 |       50 |   85.71 |   60.71 |
 src                 |    8.33 |        0 |   33.33 |    8.33 |
  App.js             |     100 |      100 |     100 |     100 |
  index.js           |       0 |      100 |     100 |       0 | 7-17
  links.js           |       0 |        0 |       0 |       0 |
  reportWebVitals.js |       0 |        0 |       0 |       0 | 1-10
 src/components      |     100 |    83.33 |     100 |     100 |
  About.jsx          |     100 |      100 |     100 |     100 |
  Event.jsx          |     100 |      100 |     100 |     100 |
  Events.jsx         |     100 |      100 |     100 |     100 |
  Footer.jsx         |     100 |       75 |     100 |     100 | 15
  Header.jsx         |     100 |      100 |     100 |     100 |
  Members.jsx        |     100 |      100 |     100 |     100 |
  Splash.jsx         |     100 |      100 |     100 |     100 |
---------------------|---------|----------|---------|---------|-------------------

Test Suites: 8 passed, 8 total
Tests:       14 passed, 14 total
Snapshots:   8 passed, 8 total
Time:        6.048 s
Ran all test suites.