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
};
jest.config.js
and look atcoveragePathIgnorePatterns
does it include anything that might match those that are missing?