-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[W-9143348] Enforce LWC Jest code coverage (#49)
* Enforce LWC Jest code coverage - Enforces 100% LWC Jest code coverage among all measures except for the following block list: - `gauExpenditureRow` - `lookup` - `manageExpenditures` - `manageExpendituresTableHeader` - We needed at least one test at 100% code coverage, so fully tested warningBanner. - For a11y, needed to change to only render `<h2>{message}</h2>` if there is a message. Else, empty headers is not allowed. - warningBanner does not yet support translations. Exported English labels so test can assert the proper labels are used. - Updated `package.json` name to follow proper naming convention. * Update force-app/main/default/lwc/warningBanner/__tests__/warningBanner.test.js Co-authored-by: Sean Cuevo <[email protected]> * Update force-app/main/default/lwc/warningBanner/__tests__/warningBanner.test.js Co-authored-by: Sean Cuevo <[email protected]> Co-authored-by: salesforce-org-metaci[bot] <53311887+salesforce-org-metaci[bot]@users.noreply.github.com> Co-authored-by: Sean Cuevo <[email protected]>
- Loading branch information
1 parent
e1bad83
commit 88592b9
Showing
6 changed files
with
220 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ jobs: | |
yarn install | ||
- name: Run Jest Tests | ||
run: | | ||
npx lwc-jest | ||
npx lwc-jest --coverage -- --passWithNoTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
const { jestConfig } = require("@salesforce/sfdx-lwc-jest/config"); | ||
|
||
const setupFilesAfterEnv = jestConfig.setupFilesAfterEnv || []; | ||
setupFilesAfterEnv.push("<rootDir>/jest.setup.js"); | ||
|
||
// Repo needs to have have 100% LWC Jest test code coverage across all measures. | ||
const coverageThreshold = jestConfig.coverageThreshold || {}; | ||
/* | ||
coverageThreshold.global = { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 0, | ||
}; | ||
*/ | ||
// TODO: All LWC Jest tests require 100% code coverage that are not in the block list specified by this glob. Remove components from the block list specified in this glob when code coverage is met. | ||
coverageThreshold[ | ||
"./force-app/main/default/lwc/!(gauExpenditureRow|lookup|manageExpenditures|manageExpendituresTableHeader)/**" | ||
] = { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 0, | ||
}; | ||
|
||
module.exports = { | ||
...jestConfig, | ||
moduleNameMapper: {}, | ||
testPathIgnorePatterns: ["force-app/main/default/lwc/__(tests|mocks)__/"], | ||
reporters: ["default"], | ||
setupFilesAfterEnv: ["./jest.setup.js"], | ||
setupFilesAfterEnv: setupFilesAfterEnv, | ||
coverageThreshold: coverageThreshold, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters