4

I can run an individual JEST test successfully for this component:

    PS C:\Users\Dave2\Documents\Visual Studio Code\TMS> npm run test:unit dispatchConsoleCalendarCell.test.js

> [email protected] test:unit
> sfdx-lwc-jest "dispatchConsoleCalendarCell.test.js"

 PASS  force-app/main/default/lwc/dispatchConsoleCalendarCell/__tests__/dispatchConsoleCalendarCell.test.js
  c-dispatch-console-calendar-cell
    √ pto calendar cell (49 ms)
    √ preferred location calendar cell (12 ms)
    √ unassigned load calendar cell (31 ms)
    √ dispatched relay load calendar cell (32 ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        2.239 s
Ran all test suites matching /dispatchConsoleCalendarCell.test.js/i.

But when I run it in coverage mode it does not show up:

npm run test:unit:coverage

dispatchConsoleCalendarCell is not shown in the coverage list. Many are missing here. They all used to be listed until a recent update of sfdx:

customerShipmentTrackingProgressIndicator     |       0 |      100 |       0 |       0 |                                                                                                                                
  customerShipmentTrackingProgressIndicator.js |       0 |      100 |       0 |       0 | 4-24                                                                                                                           
 dispatchConsole                               |       0 |        0 |       0 |       0 |                                                                                                                                
  dispatchConsole.js                           |       0 |        0 |       0 |       0 | 4-1004                                                                                                                         
 dispatchConsoleAssignments                    |       0 |        0 |       0 |       0 |                                                                                                                                
  dispatchConsoleAssignments.js                |       0 |        0 |       0 |       0 | 4-340                                                                                                                          
 dispatchConsoleDataTable                      |       0 |      100 |     100 |       0 |                                                                                                                                
  dispatchConsoleDataTable.js                  |       0 |      100 |     100 |       0 | 4-7                                                                                                                            
 dispatchConsoleDriverFilter                   |       0 |        0 |       0 |       0 |                                                                                                                                
  dispatchConsoleDriverFilter.js               |       0 |        0 |       0 |       0 | 4-447                                                                                                                          
 dispatchConsoleFleetAssignment                |       0 |        0 |       0 |       0 |                                                                                                                                
  dispatchConsoleFleetAssignment.js            |       0 |        0 |       0 |       0 | 4-767                                                                                                                          
 dispatchConsoleLoadFilter                     |       0 |        0 |       0 |       0 |                                                                                                                                
  dispatchConsoleLoadFilter.js                 |       0 |        0 |       0 |       0 | 4-457                                                                                                                          
 driverLocation                                |     100 |    66.67 |     100 |     100 |                                                                                                                                
  driverLocation.js                            |     100 |    66.67 |     100 |     100 | 69-70                                                                                                                          
 freightQuoteAssistant                         |   37.93 |    18.18 |   26.67 |   37.93 |                                                                                                                                
  freightQuoteAssistant.js                     |   37.93 |    18.18 |   26.67 |   37.93 | 51-57,67-150                                                                                                                   
 jobMonitor                                    |       0 |        0 |       0 |       0 |                                                                                                                                
  jobMonitor.js                                |       0 |        0 |       0 |       0 | 5-104                                    

Why are many LWC classes/tests now missing from the coverage run?? This used to show all of them.

From package.json:

  "scripts": {
    "test": "npm run test:unit",
    "test:unit": "sfdx-lwc-jest",
    "test:unit:debug": "sfdx-lwc-jest --debug",
    "test:unit:watch": "sfdx-lwc-jest --watch",
    "test:unit:coverage": "sfdx-lwc-jest --coverage"
  },

Thanks for your help!

Adding jest.config.js:

const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');
module.exports = {
    ...jestConfig,
    // add any custom configurations here
};
6
  • what version of lwc-jest and sfdx cli are you using? Commented Aug 18, 2021 at 18:19
  • sfdx-cli/7.113.0 win32-x64 node-v14.17.4
    – Dave C
    Commented Aug 19, 2021 at 12:44
  • "jest": "^27.0.6",
    – Dave C
    Commented Aug 19, 2021 at 12:45
  • I am also noticing that it executes all the tests too quickly -- it appears to be marking tests as successful without running them. It used to take much longer to run npm run test:unit:coverage when all the tests where correctly displayed in the coverage table.
    – Dave C
    Commented Aug 19, 2021 at 13:43
  • If you check your jest.config.js and look at coveragePathIgnorePatterns does it include anything that might match those that are missing? Commented Aug 20, 2021 at 16:20

1 Answer 1

0

I ended up deleting and recreating my project in VSCode. Fixed the problem but not sure why...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .