├── .husky
└── pre-commit
├── .gitignore
├── .prettierrc
├── CODEOWNERS
├── .editorconfig
├── src
├── lightning-stubs
│ ├── map
│ │ ├── map.html
│ │ └── map.js
│ ├── alert
│ │ ├── alert.html
│ │ └── alert.js
│ ├── avatar
│ │ ├── avatar.html
│ │ └── avatar.js
│ ├── badge
│ │ ├── badge.html
│ │ └── badge.js
│ ├── button
│ │ ├── button.html
│ │ └── button.js
│ ├── flow
│ │ ├── flow.html
│ │ └── flow.js
│ ├── icon
│ │ ├── icon.html
│ │ └── icon.js
│ ├── input
│ │ ├── input.html
│ │ └── input.js
│ ├── prompt
│ │ ├── prompt.html
│ │ └── prompt.js
│ ├── slider
│ │ ├── slider.html
│ │ └── slider.js
│ ├── tree
│ │ ├── tree.html
│ │ └── tree.js
│ ├── combobox
│ │ ├── combobox.html
│ │ └── combobox.js
│ ├── confirm
│ │ ├── confirm.html
│ │ └── confirm.js
│ ├── helptext
│ │ ├── helptext.html
│ │ └── helptext.js
│ ├── menuItem
│ │ ├── menuItem.html
│ │ └── menuItem.js
│ ├── messages
│ │ ├── messages.html
│ │ └── messages.js
│ ├── spinner
│ │ ├── spinner.html
│ │ └── spinner.js
│ ├── textarea
│ │ ├── textarea.html
│ │ └── textarea.js
│ ├── treeGrid
│ │ ├── treeGrid.html
│ │ └── treeGrid.js
│ ├── breadcrumb
│ │ ├── breadcrumb.html
│ │ └── breadcrumb.js
│ ├── buttonIcon
│ │ ├── buttonIcon.html
│ │ └── buttonIcon.js
│ ├── clickToDial
│ │ ├── clickToDial.html
│ │ └── clickToDial.js
│ ├── datatable
│ │ ├── datatable.html
│ │ └── datatable.js
│ ├── dualListbox
│ │ ├── dualListbox.html
│ │ └── dualListbox.js
│ ├── dynamicIcon
│ │ ├── dynamicIcon.html
│ │ └── dynamicIcon.js
│ ├── fileUpload
│ │ ├── fileUpload.html
│ │ └── fileUpload.js
│ ├── inputField
│ │ ├── inputField.html
│ │ └── inputField.js
│ ├── inputName
│ │ ├── inputName.html
│ │ └── inputName.js
│ ├── menuDivider
│ │ ├── menuDivider.html
│ │ └── menuDivider.js
│ ├── modalHeader
│ │ ├── modalHeader.html
│ │ └── modalHeader.js
│ ├── progressBar
│ │ ├── progressBar.html
│ │ └── progressBar.js
│ ├── radioGroup
│ │ ├── radioGroup.html
│ │ └── radioGroup.js
│ ├── recordForm
│ │ ├── recordForm.html
│ │ └── recordForm.js
│ ├── carouselImage
│ │ ├── carouselImage.html
│ │ └── carouselImage.js
│ ├── checkboxGroup
│ │ ├── checkboxGroup.html
│ │ └── checkboxGroup.js
│ ├── formattedName
│ │ ├── formattedName.html
│ │ └── formattedName.js
│ ├── formattedText
│ │ ├── formattedText.html
│ │ └── formattedText.js
│ ├── formattedTime
│ │ ├── formattedTime.html
│ │ └── formattedTime.js
│ ├── formattedUrl
│ │ ├── formattedUrl.html
│ │ └── formattedUrl.js
│ ├── inputAddress
│ │ ├── inputAddress.html
│ │ └── inputAddress.js
│ ├── inputLocation
│ │ ├── inputLocation.html
│ │ └── inputLocation.js
│ ├── menuSubheader
│ │ ├── menuSubheader.html
│ │ └── menuSubheader.js
│ ├── pillContainer
│ │ ├── pillContainer.html
│ │ └── pillContainer.js
│ ├── progressRing
│ │ ├── progressRing.html
│ │ └── progressRing.js
│ ├── progressStep
│ │ ├── progressStep.html
│ │ └── progressStep.js
│ ├── recordPicker
│ │ ├── recordPicker.html
│ │ └── recordPicker.js
│ ├── buttonStateful
│ │ ├── buttonStateful.html
│ │ └── buttonStateful.js
│ ├── formattedAddress
│ │ ├── formattedAddress.html
│ │ └── formattedAddress.js
│ ├── formattedEmail
│ │ ├── formattedEmail.html
│ │ └── formattedEmail.js
│ ├── formattedNumber
│ │ ├── formattedNumber.html
│ │ └── formattedNumber.js
│ ├── formattedPhone
│ │ ├── formattedPhone.html
│ │ └── formattedPhone.js
│ ├── overlayLibrary
│ │ ├── overlayLibrary.html
│ │ └── overlayLibrary.js
│ ├── relativeDateTime
│ │ ├── relativeDateTime.html
│ │ └── relativeDateTime.js
│ ├── buttonIconStateful
│ │ ├── buttonIconStateful.html
│ │ └── buttonIconStateful.js
│ ├── formattedDateTime
│ │ ├── formattedDateTime.html
│ │ └── formattedDateTime.js
│ ├── formattedLocation
│ │ ├── formattedLocation.html
│ │ └── formattedLocation.js
│ ├── formattedRichText
│ │ ├── formattedRichText.html
│ │ └── formattedRichText.js
│ ├── notificationsLibrary
│ │ ├── notificationsLibrary.html
│ │ └── notificationsLibrary.js
│ ├── pill
│ │ ├── pill.html
│ │ └── pill.js
│ ├── tab
│ │ ├── tab.html
│ │ └── tab.js
│ ├── verticalNavigationItem
│ │ ├── verticalNavigationItem.html
│ │ └── verticalNavigationItem.js
│ ├── layout
│ │ ├── layout.html
│ │ └── layout.js
│ ├── tabset
│ │ ├── tabset.html
│ │ └── tabset.js
│ ├── verticalNavigationItemIcon
│ │ ├── verticalNavigationItemIcon.html
│ │ └── verticalNavigationItemIcon.js
│ ├── accordion
│ │ ├── accordion.html
│ │ └── accordion.js
│ ├── buttonMenu
│ │ ├── buttonMenu.html
│ │ └── buttonMenu.js
│ ├── carousel
│ │ ├── carousel.html
│ │ └── carousel.js
│ ├── layoutItem
│ │ ├── layoutItem.html
│ │ └── layoutItem.js
│ ├── modalBody
│ │ ├── modalBody.html
│ │ └── modalBody.js
│ ├── serviceCloudVoiceToolkitApi
│ │ ├── serviceCloudVoiceToolkitApi.html
│ │ └── serviceCloudVoiceToolkitApi.js
│ ├── uiActionsApi
│ │ └── uiActionsApi.js
│ ├── uiLookupsApi
│ │ └── uiLookupsApi.js
│ ├── verticalNavigationItemBadge
│ │ ├── verticalNavigationItemBadge.html
│ │ └── verticalNavigationItemBadge.js
│ ├── breadcrumbs
│ │ ├── breadcrumbs.html
│ │ └── breadcrumbs.js
│ ├── buttonGroup
│ │ ├── buttonGroup.html
│ │ └── buttonGroup.js
│ ├── formElement
│ │ ├── formElement.html
│ │ └── formElement.js
│ ├── modalFooter
│ │ ├── modalFooter.html
│ │ └── modalFooter.js
│ ├── outputField
│ │ ├── outputField.html
│ │ └── outputField.js
│ ├── recordEditForm
│ │ ├── recordEditForm.html
│ │ └── recordEditForm.js
│ ├── recordViewForm
│ │ ├── recordViewForm.html
│ │ └── recordViewForm.js
│ ├── progressIndicator
│ │ ├── progressIndicator.html
│ │ └── progressIndicator.js
│ ├── verticalNavigation
│ │ ├── verticalNavigation.html
│ │ └── verticalNavigation.js
│ ├── inputRichText
│ │ ├── inputRichText.html
│ │ └── inputRichText.js
│ ├── richTextToolbarButton
│ │ ├── richTextToolbarButton.html
│ │ └── richTextToolbarButton.js
│ ├── tile
│ │ ├── tile.html
│ │ └── tile.js
│ ├── verticalNavigationSection
│ │ ├── verticalNavigationSection.html
│ │ └── verticalNavigationSection.js
│ ├── richTextToolbarButtonGroup
│ │ ├── richTextToolbarButtonGroup.html
│ │ └── richTextToolbarButtonGroup.js
│ ├── verticalNavigationOverflow
│ │ ├── verticalNavigationOverflow.html
│ │ └── verticalNavigationOverflow.js
│ ├── communityMicrobatchingApi
│ │ └── communityMicrobatchingApi.js
│ ├── uiListsApi
│ │ └── uiListsApi.js
│ ├── accordionSection
│ │ ├── accordionSection.html
│ │ └── accordionSection.js
│ ├── quickActionPanel
│ │ ├── quickActionPanel.html
│ │ └── quickActionPanel.js
│ ├── pageReferenceUtils
│ │ └── pageReferenceUtils.js
│ ├── platformResourceLoader
│ │ └── platformResourceLoader.js
│ ├── card
│ │ ├── card.html
│ │ └── card.js
│ ├── analyticsSmartDataDiscoveryApi
│ │ └── analyticsSmartDataDiscoveryApi.js
│ ├── uiAppsApi
│ │ └── uiAppsApi.js
│ ├── uiListApi
│ │ └── uiListApi.js
│ ├── datatableKeyboardMixins
│ │ └── datatableKeyboardMixins.js
│ ├── unstable_analyticsWavePrivateApi
│ │ └── analyticsWavePrivateApi.js
│ ├── configProvider
│ │ └── configProvider.js
│ ├── experienceMarketingIntegrationApi
│ │ └── experienceMarketingIntegrationApi.js
│ ├── toastContainer
│ │ └── toastContainer.js
│ ├── toast
│ │ └── toast.js
│ ├── empApi
│ │ └── empApi.js
│ ├── unstable_uiSearchApi
│ │ └── unstable_uiSearchApi.js
│ ├── platformShowToastEvent
│ │ └── platformShowToastEvent.js
│ ├── uiObjectInfoApi
│ │ └── uiObjectInfoApi.js
│ ├── messageService
│ │ └── messageService.js
│ ├── uiRelatedListApi
│ │ └── uiRelatedListApi.js
│ ├── navigation
│ │ └── navigation.js
│ ├── uiGraphQLApi
│ │ └── uiGraphQLApi.js
│ ├── graphql
│ │ └── graphql.js
│ ├── platformWorkspaceApi
│ │ └── platformWorkspaceApi.js
│ ├── analyticsWaveApi
│ │ └── analyticsWaveApi.js
│ └── uiRecordApi
│ │ └── uiRecordApi.js
├── utils
│ ├── __mocks__
│ │ └── project.js
│ ├── module.js
│ ├── yargs.js
│ ├── project.js
│ └── test-runner.js
├── index.js
├── log.js
├── options
│ └── options.js
├── config.js
└── resolver.js
├── config.js
├── SECURITY.md
├── tests
├── help.test.js
├── config.test.js
├── __snapshots__
│ └── help.test.js.snap
└── test-runner.test.js
├── bin
└── sfdx-lwc-jest
├── scripts
└── upgrade-lwc.sh
├── .github
├── workflows
│ └── unit.yml
├── dependabot.yml
└── ISSUE_TEMPLATE.md
├── LICENSE
├── CONTRIBUTING.md
├── eslint.config.mjs
├── package.json
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
└── README.md
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | yarn lint-staged
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | logs
2 | *.log
3 | node_modules
4 | .sfdx
5 | .vscode
6 | .DS_Store
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "tabWidth": 4,
4 | "singleQuote": true,
5 | "trailingComma": "all"
6 | }
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Comment line immediately above ownership line is reserved for related gus information. Please be careful while editing.
2 | #ECCN:Open Source
3 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | insert_final_newline = true
6 | indent_style = space
7 | indent_size = 4
8 | trim_trailing_whitespace = true
9 |
10 | [*.{json,yml}]
11 | indent_size = 2
12 |
13 | [*.md]
14 | trim_trailing_whitespace = false
--------------------------------------------------------------------------------
/src/lightning-stubs/map/map.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/alert/alert.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/avatar/avatar.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/badge/badge.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/button/button.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/flow/flow.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/icon/icon.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/input/input.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/prompt/prompt.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/slider/slider.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/tree/tree.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/combobox/combobox.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/confirm/confirm.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/helptext/helptext.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/menuItem/menuItem.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/messages/messages.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/spinner/spinner.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/textarea/textarea.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/treeGrid/treeGrid.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/breadcrumb/breadcrumb.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonIcon/buttonIcon.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/clickToDial/clickToDial.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/datatable/datatable.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/dualListbox/dualListbox.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/dynamicIcon/dynamicIcon.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/fileUpload/fileUpload.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputField/inputField.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputName/inputName.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/menuDivider/menuDivider.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/modalHeader/modalHeader.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/progressBar/progressBar.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/radioGroup/radioGroup.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/recordForm/recordForm.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/carouselImage/carouselImage.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/checkboxGroup/checkboxGroup.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedName/formattedName.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedText/formattedText.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedTime/formattedTime.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedUrl/formattedUrl.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputAddress/inputAddress.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputLocation/inputLocation.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/menuSubheader/menuSubheader.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/pillContainer/pillContainer.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/progressRing/progressRing.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/progressStep/progressStep.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/recordPicker/recordPicker.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonStateful/buttonStateful.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedAddress/formattedAddress.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedEmail/formattedEmail.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedNumber/formattedNumber.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedPhone/formattedPhone.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/overlayLibrary/overlayLibrary.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/relativeDateTime/relativeDateTime.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonIconStateful/buttonIconStateful.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedDateTime/formattedDateTime.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedLocation/formattedLocation.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedRichText/formattedRichText.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/notificationsLibrary/notificationsLibrary.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/pill/pill.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/tab/tab.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationItem/verticalNavigationItem.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/layout/layout.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/tabset/tabset.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationItemIcon/verticalNavigationItemIcon.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/accordion/accordion.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonMenu/buttonMenu.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/carousel/carousel.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/layoutItem/layoutItem.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/modalBody/modalBody.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/serviceCloudVoiceToolkitApi/serviceCloudVoiceToolkitApi.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/uiActionsApi/uiActionsApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | export const getLookupActions = jest.fn();
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/uiLookupsApi/uiLookupsApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | export const getLookupRecords = jest.fn();
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationItemBadge/verticalNavigationItemBadge.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/breadcrumbs/breadcrumbs.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonGroup/buttonGroup.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formElement/formElement.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/modalFooter/modalFooter.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/outputField/outputField.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/recordEditForm/recordEditForm.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/recordViewForm/recordViewForm.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/progressIndicator/progressIndicator.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigation/verticalNavigation.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputRichText/inputRichText.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/richTextToolbarButton/richTextToolbarButton.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/tile/tile.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationSection/verticalNavigationSection.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/config.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const { jestConfig } = require('./src/config');
10 | module.exports = { jestConfig };
11 |
--------------------------------------------------------------------------------
/src/lightning-stubs/richTextToolbarButtonGroup/richTextToolbarButtonGroup.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationOverflow/verticalNavigationOverflow.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/communityMicrobatchingApi/communityMicrobatchingApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 |
8 | export const ingestRecord = jest.fn().mockResolvedValue();
9 |
--------------------------------------------------------------------------------
/src/lightning-stubs/uiListsApi/uiListsApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | export const getListInfoByName = jest.fn();
8 | export const getListInfosByName = jest.fn();
9 |
--------------------------------------------------------------------------------
/src/lightning-stubs/accordionSection/accordionSection.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/lightning-stubs/quickActionPanel/quickActionPanel.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/lightning-stubs/modalBody/modalBody.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement } from 'lwc';
8 |
9 | export default class ModalBody extends LightningElement {}
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/breadcrumbs/breadcrumbs.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement } from 'lwc';
8 |
9 | export default class Breadcrumbs extends LightningElement {}
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonGroup/buttonGroup.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement } from 'lwc';
8 |
9 | export default class ButtonGroup extends LightningElement {}
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formElement/formElement.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement } from 'lwc';
8 |
9 | export default class FormElement extends LightningElement {}
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/modalFooter/modalFooter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement } from 'lwc';
8 |
9 | export default class ModalFooter extends LightningElement {}
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/pageReferenceUtils/pageReferenceUtils.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | export const encodeDefaultFieldValues = jest.fn();
8 | export const decodeDefaultFieldValues = jest.fn();
9 |
--------------------------------------------------------------------------------
/src/lightning-stubs/platformResourceLoader/platformResourceLoader.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | export const loadStyle = jest.fn().mockResolvedValue();
8 | export const loadScript = jest.fn().mockResolvedValue();
9 |
--------------------------------------------------------------------------------
/src/lightning-stubs/card/card.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/menuDivider/menuDivider.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class MenuDivider extends LightningElement {
10 | @api variant;
11 | }
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/modalHeader/modalHeader.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ModalHeader extends LightningElement {
10 | @api label;
11 | }
12 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | ## Security
2 |
3 | Please report any security issue to [security@salesforce.com](mailto:security@salesforce.com)
4 | as soon as it is discovered. This library limits its runtime dependencies in
5 | order to reduce the total cost of ownership as much as can be, but all consumers
6 | should remain vigilant and have their security stakeholders review all third-party
7 | products (3PP) like this one and their dependencies.
8 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedTime/formattedTime.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedTime extends LightningElement {
10 | @api value;
11 | }
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/menuSubheader/menuSubheader.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class MenuSubheader extends LightningElement {
10 | @api label;
11 | }
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/quickActionPanel/quickActionPanel.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class QuickActionPanel extends LightningElement {
10 | @api header;
11 | }
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/relativeDateTime/relativeDateTime.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class RelativeDateTime extends LightningElement {
10 | @api value;
11 | }
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/richTextToolbarButtonGroup/richTextToolbarButtonGroup.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement } from 'lwc';
8 |
9 | export default class RichTextToolbarButtonGroup extends LightningElement {}
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/tabset/tabset.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Tabset extends LightningElement {
10 | @api activeTabValue;
11 | @api variant;
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationOverflow/verticalNavigationOverflow.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement } from 'lwc';
8 |
9 | export default class VerticalNavigationOverflow extends LightningElement {}
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/messages/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Messages extends LightningElement {
10 | @api error;
11 | @api setError() {}
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/card/card.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Card extends LightningElement {
10 | @api iconName;
11 | @api title;
12 | @api variant;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/progressStep/progressStep.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ProgressStep extends LightningElement {
10 | @api label;
11 | @api value;
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedText/formattedText.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedText extends LightningElement {
10 | @api linkify;
11 | @api value;
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/tree/tree.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Tree extends LightningElement {
10 | @api header;
11 | @api items;
12 | @api selectedItem;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/accordionSection/accordionSection.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class AccordionSection extends LightningElement {
10 | @api label;
11 | @api name;
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/breadcrumb/breadcrumb.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Breadcrumb extends LightningElement {
10 | @api href;
11 | @api label;
12 | @api name;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedPhone/formattedPhone.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedPhone extends LightningElement {
10 | @api disabled;
11 | @api value;
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/spinner/spinner.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Spinner extends LightningElement {
10 | @api alternativeText;
11 | @api size;
12 | @api variant;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/tile/tile.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Tile extends LightningElement {
10 | @api actions;
11 | @api href;
12 | @api label;
13 | @api type;
14 | }
15 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationSection/verticalNavigationSection.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class VerticalNavigationSection extends LightningElement {
10 | @api label;
11 | }
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/accordion/accordion.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Accordion extends LightningElement {
10 | @api activeSectionName;
11 | @api allowMultipleSectionsOpen;
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/analyticsSmartDataDiscoveryApi/analyticsSmartDataDiscoveryApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const getStories = createLdsTestWireAdapter(jest.fn());
10 |
--------------------------------------------------------------------------------
/src/lightning-stubs/clickToDial/clickToDial.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ClickToDial extends LightningElement {
10 | @api params;
11 | @api recordId;
12 | @api value;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedLocation/formattedLocation.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedLocation extends LightningElement {
10 | @api latitude;
11 | @api longitude;
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/progressBar/progressBar.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ProgressBar extends LightningElement {
10 | @api size;
11 | @api value;
12 | @api variant;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/uiAppsApi/uiAppsApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const getNavItems = createLdsTestWireAdapter(jest.fn());
10 | export const refresh = jest.fn();
11 |
--------------------------------------------------------------------------------
/src/lightning-stubs/uiListApi/uiListApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const getListUi = createLdsTestWireAdapter(jest.fn());
10 | export const MRU = Symbol.for('MRU');
11 |
--------------------------------------------------------------------------------
/src/lightning-stubs/dynamicIcon/dynamicIcon.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class DynamicIcon extends LightningElement {
10 | @api alternativeText;
11 | @api option;
12 | @api type;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedRichText/formattedRichText.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedRichText extends LightningElement {
10 | @api disableLinkify;
11 | @api value;
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedEmail/formattedEmail.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedEmail extends LightningElement {
10 | @api hideIcon;
11 | @api label;
12 | @api value;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/carousel/carousel.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Carousel extends LightningElement {
10 | @api disableAutoRefresh;
11 | @api disableAutoScroll;
12 | @api scrollDuration;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/notificationsLibrary/notificationsLibrary.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class NotificationsLibrary extends LightningElement {
10 | @api showNotice() {}
11 | @api showToast() {}
12 | }
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/badge/badge.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Badge extends LightningElement {
10 | @api iconAlternativeText;
11 | @api iconName;
12 | @api iconPosition;
13 | @api label;
14 | }
15 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedUrl/formattedUrl.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedUrl extends LightningElement {
10 | @api label;
11 | @api target;
12 | @api tooltip;
13 | @api value;
14 | }
15 |
--------------------------------------------------------------------------------
/src/lightning-stubs/progressRing/progressRing.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ProgressRing extends LightningElement {
10 | @api direction;
11 | @api size;
12 | @api value;
13 | @api variant;
14 | }
15 |
--------------------------------------------------------------------------------
/src/lightning-stubs/serviceCloudVoiceToolkitApi/serviceCloudVoiceToolkitApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ServiceCloudVoiceToolkitApi extends LightningElement {
10 | @api updateNextBestActions() {}
11 | }
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/helptext/helptext.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Helptext extends LightningElement {
10 | @api alternativeText;
11 | @api content;
12 | @api iconName;
13 | @api iconVariant;
14 | }
15 |
--------------------------------------------------------------------------------
/src/lightning-stubs/icon/icon.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Icon extends LightningElement {
10 | @api alternativeText;
11 | @api iconName;
12 | @api size;
13 | @api src;
14 | @api variant;
15 | }
16 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigation/verticalNavigation.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class VerticalNavigation extends LightningElement {
10 | @api compact;
11 | @api selectedItem;
12 | @api shaded;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationItem/verticalNavigationItem.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class VerticalNavigationItem extends LightningElement {
10 | @api href;
11 | @api label;
12 | @api name;
13 | }
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/datatableKeyboardMixins/datatableKeyboardMixins.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { api } from 'lwc';
8 | export const baseNavigation = (superclass) => {
9 | return class extends superclass {
10 | @api keyboardMode;
11 | @api focus;
12 | };
13 | };
14 |
--------------------------------------------------------------------------------
/src/lightning-stubs/layout/layout.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Layout extends LightningElement {
10 | @api horizontalAlign;
11 | @api multipleRows;
12 | @api pullToBoundary;
13 | @api verticalAlign;
14 | }
15 |
--------------------------------------------------------------------------------
/src/lightning-stubs/progressIndicator/progressIndicator.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ProgressIndicator extends LightningElement {
10 | @api currentStep;
11 | @api hasError;
12 | @api type;
13 | @api variant;
14 | }
15 |
--------------------------------------------------------------------------------
/src/lightning-stubs/recordViewForm/recordViewForm.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class RecordViewForm extends LightningElement {
10 | @api density;
11 | @api objectApiName;
12 | @api optionalFields;
13 | @api recordId;
14 | }
15 |
--------------------------------------------------------------------------------
/src/lightning-stubs/carouselImage/carouselImage.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class CarouselImage extends LightningElement {
10 | @api alternativeText;
11 | @api description;
12 | @api header;
13 | @api href;
14 | @api src;
15 | }
16 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationItemIcon/verticalNavigationItemIcon.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class VerticalNavigationItemIcon extends LightningElement {
10 | @api href;
11 | @api iconName;
12 | @api label;
13 | @api name;
14 | }
15 |
--------------------------------------------------------------------------------
/src/utils/__mocks__/project.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | module.exports = {
10 | PROJECT_ROOT: 'projectRoot',
11 | getSfdxProjectJson: () => {
12 | return { mock: true };
13 | },
14 | getModulePaths: () => ['force-app/main/unix/lwc', 'force-app\\main\\windows\\lwc'],
15 | };
16 |
--------------------------------------------------------------------------------
/src/lightning-stubs/avatar/avatar.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Avatar extends LightningElement {
10 | @api alternativeText;
11 | @api fallbackIconName;
12 | @api initials;
13 | @api size;
14 | @api src;
15 | @api variant;
16 | }
17 |
--------------------------------------------------------------------------------
/src/lightning-stubs/unstable_analyticsWavePrivateApi/analyticsWavePrivateApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const executeQuery = createLdsTestWireAdapter(jest.fn());
10 |
11 | export const getJwt = createLdsTestWireAdapter(jest.fn());
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/configProvider/configProvider.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | export default jest.fn();
8 | export const getPathPrefix = jest.fn();
9 | export const getToken = jest.fn();
10 | export const getLocalizationService = jest.fn();
11 | export const getIconSvgTemplates = jest.fn();
12 | export const getOneConfig = jest.fn();
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/outputField/outputField.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class OutputField extends LightningElement {
10 | @api fieldClass;
11 | @api fieldName;
12 | @api variant;
13 | @api wirePicklistValues() {}
14 | @api wireRecordUi() {}
15 | }
16 |
--------------------------------------------------------------------------------
/src/lightning-stubs/experienceMarketingIntegrationApi/experienceMarketingIntegrationApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const getForm = createLdsTestWireAdapter(jest.fn());
10 | export const saveForm = jest.fn();
11 | export const submitForm = jest.fn();
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/pillContainer/pillContainer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class PillContainer extends LightningElement {
10 | @api isCollapsible;
11 | @api isExpanded;
12 | @api items;
13 | @api label;
14 | @api singleLine;
15 | @api variant;
16 | }
17 |
--------------------------------------------------------------------------------
/src/lightning-stubs/toastContainer/toastContainer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ToastContainer extends LightningElement {
10 | static instance() {}
11 | @api containerPosition;
12 | @api maxToasts;
13 | @api toastPosition;
14 | @api close() {}
15 | }
16 |
--------------------------------------------------------------------------------
/src/lightning-stubs/overlayLibrary/overlayLibrary.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class OverlayLibrary extends LightningElement {
10 | @api close() {}
11 | @api hide() {}
12 | @api show() {}
13 | @api showCustomModal() {}
14 | @api showCustomPopover() {}
15 | }
16 |
--------------------------------------------------------------------------------
/src/lightning-stubs/pill/pill.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Pill extends LightningElement {
10 | @api hasError;
11 | @api href;
12 | @api isPlainLink;
13 | @api label;
14 | @api name;
15 | @api role;
16 | @api variant;
17 | @api focusLink() {}
18 | }
19 |
--------------------------------------------------------------------------------
/src/lightning-stubs/flow/flow.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Flow extends LightningElement {
10 | @api flowApiName;
11 | @api flowFinishBehavior;
12 | @api flowInputVariables;
13 | @api flowInterviewId;
14 | @api resumeFlow() {}
15 | @api startFlow() {}
16 | }
17 |
--------------------------------------------------------------------------------
/src/lightning-stubs/verticalNavigationItemBadge/verticalNavigationItemBadge.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class VerticalNavigationItemBadge extends LightningElement {
10 | @api assistiveText;
11 | @api badgeCount;
12 | @api href;
13 | @api label;
14 | @api name;
15 | }
16 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedName/formattedName.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedName extends LightningElement {
10 | @api firstName;
11 | @api format;
12 | @api informalName;
13 | @api lastName;
14 | @api middleName;
15 | @api salutation;
16 | @api suffix;
17 | }
18 |
--------------------------------------------------------------------------------
/src/lightning-stubs/toast/toast.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Toast extends LightningElement {
10 | static show() {}
11 |
12 | @api labelLinks;
13 | @api messageLinks;
14 | @api label;
15 | @api message;
16 | @api variant;
17 | @api mode;
18 | @api focus() {}
19 | }
20 |
--------------------------------------------------------------------------------
/src/lightning-stubs/empApi/empApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | export const subscribe = jest.fn().mockResolvedValue({});
8 | export const unsubscribe = jest.fn().mockResolvedValue({});
9 | export const onError = jest.fn().mockResolvedValue(jest.fn());
10 | export const setDebugFlag = jest.fn().mockResolvedValue();
11 | export const isEmpEnabled = jest.fn().mockResolvedValue();
12 |
--------------------------------------------------------------------------------
/src/lightning-stubs/map/map.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Map extends LightningElement {
10 | @api center;
11 | @api listView;
12 | @api mapMarkers;
13 | @api markersTitle;
14 | @api options;
15 | @api selectedMarkerValue;
16 | @api showFooter;
17 | @api zoomLevel;
18 | }
19 |
--------------------------------------------------------------------------------
/src/lightning-stubs/layoutItem/layoutItem.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class LayoutItem extends LightningElement {
10 | @api alignmentBump;
11 | @api flexibility;
12 | @api largeDeviceSize;
13 | @api mediumDeviceSize;
14 | @api padding;
15 | @api size;
16 | @api smallDeviceSize;
17 | }
18 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonIconStateful/buttonIconStateful.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ButtonIconStateful extends LightningElement {
10 | @api alternativeText;
11 | @api disabled;
12 | @api iconName;
13 | @api name;
14 | @api selected;
15 | @api size;
16 | @api value;
17 | @api variant;
18 | }
19 |
--------------------------------------------------------------------------------
/src/lightning-stubs/tab/tab.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Tab extends LightningElement {
10 | @api endIconAlternativeText;
11 | @api endIconName;
12 | @api iconAssistiveText;
13 | @api iconName;
14 | @api label;
15 | @api showErrorIndicator;
16 | @api value;
17 | @api loadContent() {}
18 | }
19 |
--------------------------------------------------------------------------------
/tests/help.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const { exec } = require('child_process');
10 | const { promisify } = require('util');
11 |
12 | const promiseExec = promisify(exec);
13 |
14 | test('--help attribute shows help', async () => {
15 | const { stdout } = await promiseExec('node ./bin/sfdx-lwc-jest --help');
16 | expect(stdout).toMatchSnapshot();
17 | });
18 |
--------------------------------------------------------------------------------
/src/lightning-stubs/recordForm/recordForm.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class RecordForm extends LightningElement {
10 | @api columns;
11 | @api density;
12 | @api fields;
13 | @api layoutType;
14 | @api mode;
15 | @api objectApiName;
16 | @api recordId;
17 | @api recordTypeId;
18 | @api submit() {}
19 | }
20 |
--------------------------------------------------------------------------------
/src/lightning-stubs/button/button.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Button extends LightningElement {
10 | @api disabled;
11 | @api iconName;
12 | @api iconPosition;
13 | @api label;
14 | @api name;
15 | @api type;
16 | @api value;
17 | @api variant;
18 | @api disableAnimation;
19 | @api stretch;
20 | }
21 |
--------------------------------------------------------------------------------
/src/lightning-stubs/richTextToolbarButton/richTextToolbarButton.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class RichTextToolbarButton extends LightningElement {
10 | @api disabled;
11 | @api groupOrder;
12 | @api iconAlternativeText;
13 | @api iconName;
14 | @api selected;
15 | @api closePopup() {}
16 | @api showPopup() {}
17 | }
18 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonIcon/buttonIcon.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ButtonIcon extends LightningElement {
10 | @api alternativeText;
11 | @api disabled;
12 | @api iconClass;
13 | @api iconName;
14 | @api name;
15 | @api size;
16 | @api tooltip;
17 | @api type;
18 | @api value;
19 | @api variant;
20 | }
21 |
--------------------------------------------------------------------------------
/src/lightning-stubs/unstable_uiSearchApi/unstable_uiSearchApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const unstable_getSearchResults = createLdsTestWireAdapter(jest.fn());
10 | export const unstable_getKeywordSearchResults = createLdsTestWireAdapter(jest.fn());
11 | export const unstable_getSearchFilterOptions = createLdsTestWireAdapter(jest.fn());
12 |
--------------------------------------------------------------------------------
/src/utils/module.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const path = require('path');
10 |
11 | const PATH_TO_MODULES = path.join('main', 'default', 'lwc');
12 |
13 | function getInfoFromId(id) {
14 | const [ns, ...rest] = id.split('/');
15 | return {
16 | ns,
17 | name: rest.join('/'),
18 | };
19 | }
20 |
21 | module.exports = {
22 | PATH_TO_MODULES,
23 | getInfoFromId,
24 | };
25 |
--------------------------------------------------------------------------------
/src/lightning-stubs/recordEditForm/recordEditForm.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class RecordEditForm extends LightningElement {
10 | @api density;
11 | @api fieldNames;
12 | @api formClass;
13 | @api layoutType;
14 | @api objectApiName;
15 | @api optionalFields;
16 | @api recordId;
17 | @api recordTypeId;
18 | @api submit() {}
19 | }
20 |
--------------------------------------------------------------------------------
/src/lightning-stubs/alert/alert.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Alert extends LightningElement {
10 | static open() {
11 | throw new Error(
12 | 'The LightningAlert documentation contains examples for mocking .open in Jest',
13 | );
14 | }
15 | @api label;
16 | @api message;
17 | @api theme;
18 | @api variant;
19 | }
20 |
--------------------------------------------------------------------------------
/src/lightning-stubs/platformShowToastEvent/platformShowToastEvent.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | const ShowToastEventName = 'lightning__showtoast';
8 |
9 | export class ShowToastEvent extends CustomEvent {
10 | constructor(toast) {
11 | super(ShowToastEventName, {
12 | composed: true,
13 | cancelable: true,
14 | bubbles: true,
15 | detail: toast,
16 | });
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/lightning-stubs/confirm/confirm.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Confirm extends LightningElement {
10 | static open() {
11 | throw new Error(
12 | 'The LightningConfirm documentation contains examples for mocking .open in Jest',
13 | );
14 | }
15 | @api label;
16 | @api message;
17 | @api theme;
18 | @api variant;
19 | }
20 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedAddress/formattedAddress.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedAddress extends LightningElement {
10 | @api city;
11 | @api country;
12 | @api disabled;
13 | @api latitude;
14 | @api locale;
15 | @api longitude;
16 | @api postalCode;
17 | @api province;
18 | @api showStaticMap;
19 | @api street;
20 | }
21 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonStateful/buttonStateful.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ButtonStateful extends LightningElement {
10 | @api groupOrder;
11 | @api iconNameWhenHover;
12 | @api iconNameWhenOff;
13 | @api iconNameWhenOn;
14 | @api labelWhenHover;
15 | @api labelWhenOff;
16 | @api labelWhenOn;
17 | @api selected;
18 | @api variant;
19 | }
20 |
--------------------------------------------------------------------------------
/src/lightning-stubs/menuItem/menuItem.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class MenuItem extends LightningElement {
10 | @api checked;
11 | @api disabled;
12 | @api download;
13 | @api draftAlternativeText;
14 | @api href;
15 | @api iconName;
16 | @api isDraft;
17 | @api label;
18 | @api prefixIconName;
19 | @api target;
20 | @api value;
21 | }
22 |
--------------------------------------------------------------------------------
/src/lightning-stubs/uiObjectInfoApi/uiObjectInfoApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const getObjectInfo = createLdsTestWireAdapter(jest.fn());
10 | export const getObjectInfos = createLdsTestWireAdapter(jest.fn());
11 | export const getPicklistValues = createLdsTestWireAdapter(jest.fn());
12 | export const getPicklistValuesByRecordType = createLdsTestWireAdapter(jest.fn());
13 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedDateTime/formattedDateTime.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedDateTime extends LightningElement {
10 | @api day;
11 | @api era;
12 | @api hour;
13 | @api hour12;
14 | @api minute;
15 | @api month;
16 | @api second;
17 | @api timeZone;
18 | @api timeZoneName;
19 | @api value;
20 | @api weekday;
21 | @api year;
22 | }
23 |
--------------------------------------------------------------------------------
/src/lightning-stubs/prompt/prompt.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Prompt extends LightningElement {
10 | static open() {
11 | throw new Error(
12 | 'The LightningPrompt documentation contains examples for mocking .open in Jest',
13 | );
14 | }
15 | @api defaultValue;
16 | @api label;
17 | @api message;
18 | @api theme;
19 | @api variant;
20 | }
21 |
--------------------------------------------------------------------------------
/src/lightning-stubs/fileUpload/fileUpload.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FileUpload extends LightningElement {
10 | @api accept;
11 | @api disabled;
12 | @api fileFieldName;
13 | @api fileFieldValue;
14 | @api label;
15 | @api multiple;
16 | @api name;
17 | @api recordId;
18 | @api required;
19 | @api reportValidity() {}
20 | @api setCustomValidity() {}
21 | }
22 |
--------------------------------------------------------------------------------
/src/lightning-stubs/formattedNumber/formattedNumber.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class FormattedNumber extends LightningElement {
10 | @api currencyCode;
11 | @api currencyDisplayAs;
12 | @api formatStyle;
13 | @api maximumFractionDigits;
14 | @api maximumSignificantDigits;
15 | @api minimumFractionDigits;
16 | @api minimumIntegerDigits;
17 | @api minimumSignificantDigits;
18 | @api value;
19 | }
20 |
--------------------------------------------------------------------------------
/bin/sfdx-lwc-jest:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | /*
4 | * Copyright (c) 2018, salesforce.com, inc.
5 | * All rights reserved.
6 | * SPDX-License-Identifier: MIT
7 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8 | */
9 | 'use strict';
10 |
11 | const { getArgs } = require('../src/utils/yargs');
12 | const { error } = require('../src/log');
13 |
14 | const args = getArgs();
15 | const runJest = require('../src/utils/test-runner');
16 |
17 | runJest(args)
18 | .catch((err) => {
19 | error(err);
20 | return 1;
21 | })
22 | .then((code) => {
23 | process.exit(code);
24 | });
25 |
26 | process.on('unhandledRejection', (reason) => {
27 | error(reason);
28 | });
29 |
--------------------------------------------------------------------------------
/src/lightning-stubs/checkboxGroup/checkboxGroup.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class CheckboxGroup extends LightningElement {
10 | @api disabled;
11 | @api label;
12 | @api messageWhenValueMissing;
13 | @api name;
14 | @api options;
15 | @api required;
16 | @api validity;
17 | @api value;
18 | @api variant;
19 | @api checkValidity() {}
20 | @api reportValidity() {}
21 | @api setCustomValidity() {}
22 | @api showHelpMessageIfInvalid() {}
23 | }
24 |
--------------------------------------------------------------------------------
/scripts/upgrade-lwc.sh:
--------------------------------------------------------------------------------
1 | #/bin/bash -e
2 |
3 | # Copyright (c) 2018, salesforce.com, inc.
4 | # All rights reserved.
5 | # SPDX-License-Identifier: MIT
6 | # For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7 |
8 | LWC_VERSION=$1
9 | LWC_TEST_VERSION=$2
10 |
11 | yarn upgrade \
12 | @lwc/compiler@$LWC_VERSION \
13 | @lwc/engine-dom@$LWC_VERSION \
14 | @lwc/engine-server@$LWC_VERSION \
15 | @lwc/module-resolver@$LWC_VERSION \
16 | @lwc/wire-service@$LWC_VERSION \
17 | @lwc/synthetic-shadow@$LWC_VERSION \
18 | @lwc/jest-resolver@$LWC_TEST_VERSION \
19 | @lwc/jest-serializer@$LWC_TEST_VERSION \
20 | @lwc/jest-transformer@$LWC_TEST_VERSION \
21 | @lwc/jest-preset@$LWC_TEST_VERSION \
22 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputField/inputField.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class InputField extends LightningElement {
10 | @api dirty;
11 | @api disabled;
12 | @api fieldName;
13 | @api readOnly;
14 | @api required;
15 | @api value;
16 | @api variant;
17 | @api clean() {}
18 | @api reportValidity() {}
19 | @api reset() {}
20 | @api setErrors() {}
21 | @api updateDependentField() {}
22 | @api wirePicklistValues() {}
23 | @api wireRecordUi() {}
24 | }
25 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputLocation/inputLocation.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class InputLocation extends LightningElement {
10 | @api disabled;
11 | @api fieldLevelHelp;
12 | @api label;
13 | @api latitude;
14 | @api longitude;
15 | @api readOnly;
16 | @api required;
17 | @api validity;
18 | @api variant;
19 | @api checkValidity() {}
20 | @api reportValidity() {}
21 | @api setCustomValidityForField() {}
22 | @api showHelpMessageIfInvalid() {}
23 | }
24 |
--------------------------------------------------------------------------------
/src/lightning-stubs/messageService/messageService.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const APPLICATION_SCOPE = Symbol('APPLICATION_SCOPE');
10 | export const createMessageChannel = jest.fn();
11 | export const createMessageContext = jest.fn();
12 | export const MessageContext = createTestWireAdapter(jest.fn());
13 | export const publish = jest.fn();
14 | export const releaseMessageContext = jest.fn();
15 | export const subscribe = jest.fn();
16 | export const unsubscribe = jest.fn();
17 |
--------------------------------------------------------------------------------
/src/lightning-stubs/radioGroup/radioGroup.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class RadioGroup extends LightningElement {
10 | @api disabled;
11 | @api label;
12 | @api messageWhenValueMissing;
13 | @api name;
14 | @api options;
15 | @api required;
16 | @api type;
17 | @api validity;
18 | @api value;
19 | @api variant;
20 | @api checkValidity() {}
21 | @api reportValidity() {}
22 | @api setCustomValidity() {}
23 | @api showHelpMessageIfInvalid() {}
24 | }
25 |
--------------------------------------------------------------------------------
/src/lightning-stubs/buttonMenu/buttonMenu.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class ButtonMenu extends LightningElement {
10 | @api alternativeText;
11 | @api disabled;
12 | @api draftAlternativeText;
13 | @api groupOrder;
14 | @api iconName;
15 | @api iconSize;
16 | @api isDraft;
17 | @api isLoading;
18 | @api label;
19 | @api loadingStateAlternativeText;
20 | @api menuAlignment;
21 | @api nubbin;
22 | @api tooltip;
23 | @api value;
24 | @api variant;
25 | }
26 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const {
10 | createApexTestWireAdapter,
11 | createLdsTestWireAdapter,
12 | createTestWireAdapter,
13 | registerLdsTestWireAdapter,
14 | registerApexTestWireAdapter,
15 | registerTestWireAdapter,
16 | } = require('@salesforce/wire-service-jest-util');
17 |
18 | module.exports = {
19 | createApexTestWireAdapter,
20 | createLdsTestWireAdapter,
21 | createTestWireAdapter,
22 | registerLdsTestWireAdapter,
23 | registerApexTestWireAdapter,
24 | registerTestWireAdapter,
25 | };
26 |
--------------------------------------------------------------------------------
/tests/config.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | jest.mock('../src/utils/project');
10 | const { jestConfig } = require('../src/config');
11 |
12 | test('coveragePaths correctly build', () => {
13 | expect(jestConfig.collectCoverageFrom).toStrictEqual([
14 | 'force-app/main/unix/lwc/**/*',
15 | '!force-app/main/unix/lwc/**/*.html',
16 | '!force-app/main/unix/lwc/**/*.css',
17 | 'force-app/main/windows/lwc/**/*',
18 | '!force-app/main/windows/lwc/**/*.html',
19 | '!force-app/main/windows/lwc/**/*.css',
20 | ]);
21 | });
22 |
--------------------------------------------------------------------------------
/src/lightning-stubs/uiRelatedListApi/uiRelatedListApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const getRelatedListCount = createLdsTestWireAdapter(jest.fn());
10 | export const getRelatedListInfo = createLdsTestWireAdapter(jest.fn());
11 | export const getRelatedListInfoBatch = createLdsTestWireAdapter(jest.fn());
12 | export const getRelatedListRecordsBatch = createLdsTestWireAdapter(jest.fn());
13 | export const getRelatedListRecords = createLdsTestWireAdapter(jest.fn());
14 | export const getRelatedListsInfo = createLdsTestWireAdapter(jest.fn());
15 |
--------------------------------------------------------------------------------
/src/lightning-stubs/recordPicker/recordPicker.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class RecordPicker extends LightningElement {
10 | @api disabled;
11 | @api displayInfo;
12 | @api fieldLevelHelp;
13 | @api filter;
14 | @api label;
15 | @api matchingInfo;
16 | @api messageWhenBadInput;
17 | @api objectApiName;
18 | @api placeholder;
19 | @api required;
20 | @api value;
21 | @api variant;
22 | @api checkValidity() {}
23 | @api clearSelection() {}
24 | @api reportValidity() {}
25 | @api setCustomValidity() {}
26 | }
27 |
--------------------------------------------------------------------------------
/src/lightning-stubs/navigation/navigation.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const CurrentPageReference = createTestWireAdapter(jest.fn());
10 |
11 | const Navigate = Symbol('Navigate');
12 | const GenerateUrl = Symbol('GenerateUrl');
13 | export const NavigationMixin = (Base) => {
14 | return class extends Base {
15 | [Navigate]() {}
16 | [GenerateUrl]() {
17 | return Promise.resolve('https://www.example.com');
18 | }
19 | };
20 | };
21 | NavigationMixin.Navigate = Navigate;
22 | NavigationMixin.GenerateUrl = GenerateUrl;
23 |
--------------------------------------------------------------------------------
/src/lightning-stubs/treeGrid/treeGrid.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class TreeGrid extends LightningElement {
10 | @api columns;
11 | @api data;
12 | @api expandedRows;
13 | @api hideCheckboxColumn;
14 | @api isLoading;
15 | @api keyField;
16 | @api maxColumnWidth;
17 | @api minColumnWidth;
18 | @api resizeColumnDisabled;
19 | @api rowNumberOffset;
20 | @api selectedRows;
21 | @api showRowNumberColumn;
22 | @api collapseAll() {}
23 | @api expandAll() {}
24 | @api getCurrentExpandedRows() {}
25 | @api getSelectedRows() {}
26 | }
27 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputRichText/inputRichText.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class InputRichText extends LightningElement {
10 | @api customButtons;
11 | @api disabled;
12 | @api disabledCategories;
13 | @api fieldLevelHelp;
14 | @api formats;
15 | @api label;
16 | @api labelVisible;
17 | @api messageWhenBadInput;
18 | @api placeholder;
19 | @api required;
20 | @api shareWithEntityId;
21 | @api valid;
22 | @api value;
23 | @api variant;
24 | @api getFormat() {}
25 | @api insertTextAtCursor() {}
26 | @api setFormat() {}
27 | @api setRangeText() {}
28 | }
29 |
--------------------------------------------------------------------------------
/src/lightning-stubs/combobox/combobox.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Combobox extends LightningElement {
10 | @api autocomplete;
11 | @api disabled;
12 | @api dropdownAlignment;
13 | @api fieldLevelHelp;
14 | @api label;
15 | @api messageWhenValueMissing;
16 | @api name;
17 | @api options;
18 | @api placeholder;
19 | @api readOnly;
20 | @api required;
21 | @api spinnerActive;
22 | @api validity;
23 | @api value;
24 | @api variant;
25 | @api checkValidity() {}
26 | @api reportValidity() {}
27 | @api setCustomValidity() {}
28 | @api showHelpMessageIfInvalid() {}
29 | }
30 |
--------------------------------------------------------------------------------
/src/log.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | function blue(message) {
10 | // equivalent to chalk.blue()
11 | return `\x1B[34m${message}\x1B[39m`;
12 | }
13 |
14 | function yellow(message) {
15 | // equivalent to chalk.yellow()
16 | return `\x1B[33m${message}\x1B[39m`;
17 | }
18 |
19 | function red(message) {
20 | // equivalent to chalk.red()
21 | return `\x1B[31m${message}\x1B[39m`;
22 | }
23 |
24 | function info(message) {
25 | console.log(`${blue('info')} ${message}`);
26 | }
27 |
28 | function warn(message) {
29 | console.warn(`${yellow('warn')} ${message}`);
30 | }
31 |
32 | function error(message) {
33 | console.error(`${red('error')} ${message}`);
34 | }
35 |
36 | module.exports = {
37 | info,
38 | warn,
39 | error,
40 | };
41 |
--------------------------------------------------------------------------------
/src/lightning-stubs/textarea/textarea.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Textarea extends LightningElement {
10 | @api autocomplete;
11 | @api disabled;
12 | @api fieldLevelHelp;
13 | @api label;
14 | @api maxLength;
15 | @api messageWhenBadInput;
16 | @api messageWhenTooLong;
17 | @api messageWhenTooShort;
18 | @api messageWhenValueMissing;
19 | @api minLength;
20 | @api name;
21 | @api placeholder;
22 | @api readOnly;
23 | @api required;
24 | @api validity;
25 | @api value;
26 | @api variant;
27 | @api checkValidity() {}
28 | @api reportValidity() {}
29 | @api setCustomValidity() {}
30 | @api setRangeText() {}
31 | @api showHelpMessageIfInvalid() {}
32 | }
33 |
--------------------------------------------------------------------------------
/src/lightning-stubs/slider/slider.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Slider extends LightningElement {
10 | @api disabled;
11 | @api label;
12 | @api max;
13 | @api messageWhenBadInput;
14 | @api messageWhenPatternMismatch;
15 | @api messageWhenRangeOverflow;
16 | @api messageWhenRangeUnderflow;
17 | @api messageWhenStepMismatch;
18 | @api messageWhenTooLong;
19 | @api messageWhenTypeMismatch;
20 | @api messageWhenValueMissing;
21 | @api min;
22 | @api size;
23 | @api step;
24 | @api type;
25 | @api validity;
26 | @api value;
27 | @api variant;
28 | @api checkValidity() {}
29 | @api reportValidity() {}
30 | @api setCustomValidity() {}
31 | @api showHelpMessageIfInvalid() {}
32 | }
33 |
--------------------------------------------------------------------------------
/src/lightning-stubs/uiGraphQLApi/uiGraphQLApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | /**
10 | * @deprecated import from lightning/graphql instead
11 | */
12 | export class graphql extends createTestWireAdapter() {
13 | static emit(value, filterFn) {
14 | super.emit({ data: value, errors: undefined }, filterFn);
15 | }
16 |
17 | static emitErrors(errors, filterFn) {
18 | super.emit({ data: undefined, errors }, filterFn);
19 | }
20 |
21 | constructor(dataCallback) {
22 | super(dataCallback);
23 |
24 | graphql.emit(undefined);
25 | }
26 | }
27 |
28 | /**
29 | * @deprecated import from lightning/graphql instead
30 | */
31 | export const gql = jest.fn();
32 | export const refreshGraphQL = jest.fn();
33 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputName/inputName.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class InputName extends LightningElement {
10 | @api disabled;
11 | @api fieldLevelHelp;
12 | @api fieldsToDisplay;
13 | @api firstName;
14 | @api firstNameLabel;
15 | @api informalName;
16 | @api informalNameLabel;
17 | @api label;
18 | @api lastName;
19 | @api lastNameLabel;
20 | @api middleName;
21 | @api middleNameLabel;
22 | @api options;
23 | @api readOnly;
24 | @api required;
25 | @api salutation;
26 | @api salutationLabel;
27 | @api suffix;
28 | @api suffixLabel;
29 | @api validity;
30 | @api variant;
31 | @api checkValidity() {}
32 | @api reportValidity() {}
33 | @api setCustomValidityForField() {}
34 | @api showHelpMessageIfInvalid() {}
35 | }
36 |
--------------------------------------------------------------------------------
/.github/workflows/unit.yml:
--------------------------------------------------------------------------------
1 | name: Lint and unit tests
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | - 'spring*'
8 | - 'summer*'
9 | - 'winter*'
10 | pull_request:
11 | branches:
12 | - master
13 | - 'spring*'
14 | - 'summer*'
15 | - 'winter*'
16 |
17 | jobs:
18 | lint-unit-tests:
19 | runs-on: ubuntu-22.04
20 | steps:
21 | - name: Checkout repository
22 | uses: actions/checkout@v4
23 |
24 | - name: Setup Node
25 | uses: actions/setup-node@v4
26 | with:
27 | node-version: '24.11.0'
28 | cache: 'yarn'
29 |
30 | - name: Install dependencies
31 | run: yarn install --frozen-lockfile
32 |
33 | - name: Check formatting
34 | run: yarn format:check
35 |
36 | - name: Run linter
37 | run: yarn lint
38 |
39 | - name: Run unit tests
40 | run: yarn test
41 |
42 |
43 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # Please see the documentation for all configuration options:
2 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
3 |
4 | version: 2
5 | updates:
6 | - package-ecosystem: "npm" # See documentation for possible values
7 | directory: "/" # Location of package manifests
8 | schedule:
9 | interval: "monthly"
10 | groups:
11 | # Group all lwc-test (aka `lwc/jest-*`) deps together since they all depend on each other
12 | # See: https://github.com/salesforce/lwc-test
13 | lwc-test:
14 | patterns:
15 | - "@lwc/jest-*"
16 | # Group other lwc deps together since they also all depend on each other
17 | # See: https://github.com/salesforce/lwc
18 | lwc:
19 | patterns:
20 | - "@lwc/*"
21 | # Non-major version bumps hopefully shouldn't break anything,
22 | # so let's group them together into a single PR!
23 | theoretically-non-breaking:
24 | update-types:
25 | - "minor"
26 | - "patch"
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT LICENSE
2 |
3 | Copyright (c) 2018, Salesforce.com, Inc.
4 | All rights reserved.
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7 |
8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 |
10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 |
--------------------------------------------------------------------------------
/src/lightning-stubs/dualListbox/dualListbox.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class DualListbox extends LightningElement {
10 | @api addButtonLabel;
11 | @api disableReordering;
12 | @api disabled;
13 | @api downButtonLabel;
14 | @api fieldLevelHelp;
15 | @api label;
16 | @api max;
17 | @api messageWhenRangeOverflow;
18 | @api messageWhenRangeUnderflow;
19 | @api messageWhenValueMissing;
20 | @api min;
21 | @api name;
22 | @api options;
23 | @api removeButtonLabel;
24 | @api required;
25 | @api requiredOptions;
26 | @api selectedLabel;
27 | @api showActivityIndicator;
28 | @api size;
29 | @api sourceLabel;
30 | @api upButtonLabel;
31 | @api validity;
32 | @api value;
33 | @api variant;
34 | @api checkValidity() {}
35 | @api reportValidity() {}
36 | @api setCustomValidity() {}
37 | @api showHelpMessageIfInvalid() {}
38 | }
39 |
--------------------------------------------------------------------------------
/src/lightning-stubs/graphql/graphql.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 | export class graphql extends createTestWireAdapter() {
9 | static emit(value, filterFn, refreshFn) {
10 | super.emit(
11 | {
12 | data: value,
13 | errors: undefined,
14 | ...(refreshFn !== undefined && { refresh: refreshFn }),
15 | },
16 | filterFn,
17 | );
18 | }
19 |
20 | static emitErrors(errors, filterFn, refreshFn) {
21 | super.emit(
22 | {
23 | data: undefined,
24 | errors,
25 | ...(refreshFn !== undefined && { refresh: refreshFn }),
26 | },
27 | filterFn,
28 | );
29 | }
30 |
31 | constructor(dataCallback) {
32 | super(dataCallback);
33 |
34 | graphql.emit(undefined);
35 | }
36 | }
37 | export const gql = jest.fn();
38 |
--------------------------------------------------------------------------------
/src/lightning-stubs/datatable/datatable.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Datatable extends LightningElement {
10 | @api columnWidthsMode;
11 | @api columns;
12 | @api data;
13 | @api defaultSortDirection;
14 | @api draftValues;
15 | @api enableInfiniteLoading;
16 | @api errors;
17 | @api hideCheckboxColumn;
18 | @api hideTableHeader;
19 | @api isLoading;
20 | @api keyField;
21 | @api loadMoreOffset;
22 | @api maxColumnWidth;
23 | @api maxRowSelection;
24 | @api minColumnWidth;
25 | @api renderConfig;
26 | @api renderMode;
27 | @api resizeColumnDisabled;
28 | @api resizeStep;
29 | @api rowNumberOffset;
30 | @api selectedRows;
31 | @api showRowNumberColumn;
32 | @api sortedBy;
33 | @api sortedDirection;
34 | @api suppressBottomBar;
35 | @api wrapTableHeader;
36 | @api wrapTextMaxLines;
37 | @api getSelectedRows() {}
38 | @api openInlineEdit() {}
39 | }
40 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Before contributing to this repository make sure to discuss first the intended changes either by creating a new issue or commenting an existing one.
4 |
5 | ## Useful commands
6 |
7 | Once the repository has been cloned you can run the following commands from the root directory.
8 |
9 | ```sh
10 | $ yarn install # install project dependencies
11 | $ yarn lint # run linting against project code
12 | $ yarn test # run test
13 | ```
14 |
15 | ## Submitting code
16 |
17 | Any code change should be submitted as a pull request. The description should explain what the code does and give steps to execute it. The pull request should also contain tests.
18 |
19 | ## Review process
20 |
21 | The bigger the pull request, the longer it will take to review and merge. Try to break down large pull requests in smaller chunks that are easier to review and merge. Also make sure to reference the related issues in the pull request message if any.
22 |
23 | ## Release
24 |
25 | Each `winter*`, `spring*` and `summer*` branch/dist tag is the version of this package used for the corresponding Salesforce release. The `latest` dist tag corresponds to the latest Salesforce release, rather than the most recent code changes from the `master` branch. New code changes from `master` are published to the `prerelease` tag.
26 |
--------------------------------------------------------------------------------
/src/lightning-stubs/inputAddress/inputAddress.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class InputAddress extends LightningElement {
10 | @api addressLabel;
11 | @api addressLookupLabel;
12 | @api addressLookupPlaceholder;
13 | @api city;
14 | @api cityLabel;
15 | @api cityPlaceholder;
16 | @api country;
17 | @api countryDisabled;
18 | @api countryLabel;
19 | @api countryOptions;
20 | @api countryPlaceholder;
21 | @api disabled;
22 | @api fieldLevelHelp;
23 | @api locale;
24 | @api postalCode;
25 | @api postalCodeLabel;
26 | @api postalCodePlaceholder;
27 | @api province;
28 | @api provinceLabel;
29 | @api provinceOptions;
30 | @api provincePlaceholder;
31 | @api readOnly;
32 | @api required;
33 | @api showAddressLookup;
34 | @api street;
35 | @api streetLabel;
36 | @api streetPlaceholder;
37 | @api validity;
38 | @api variant;
39 | @api checkValidity() {}
40 | @api reportValidity() {}
41 | @api setCustomValidityForField() {}
42 | @api showHelpMessageIfInvalid() {}
43 | }
44 |
--------------------------------------------------------------------------------
/src/utils/yargs.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const yargs = require('yargs');
10 |
11 | const { error, info } = require('../log');
12 | const options = require('../options/options');
13 |
14 | const argError = (msg, err, yargs) => {
15 | if (err) {
16 | throw err;
17 | }
18 |
19 | let unrecognized;
20 | let token = 'Unknown argument: ';
21 | if (msg.startsWith(token)) {
22 | unrecognized = msg.substring(token.length);
23 | }
24 |
25 | let template =
26 | `The following argument(s) are not recognized by lwc-jest: ${unrecognized}\n` +
27 | `If you wish to pass these arguments along to Jest, please add the '--' flag`;
28 |
29 | info(yargs.help());
30 | error(template);
31 | };
32 |
33 | const getArgs = () => {
34 | return yargs
35 | .usage('`$0 [options]` runs Jest unit tests in SFDX workspace')
36 | .example('$0 --coverage', options.coverage.description)
37 | .example('$0 -- --json', 'All params after `--` are directly passed to Jest')
38 | .options(options)
39 | .strict()
40 | .fail(argError)
41 | .help().argv;
42 | };
43 |
44 | module.exports = { getArgs };
45 |
--------------------------------------------------------------------------------
/src/options/options.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const testOptions = {
10 | coverage: {
11 | description: 'Collect coverage and display in output',
12 | type: 'boolean',
13 | default: false,
14 | },
15 |
16 | updateSnapshot: {
17 | description: 'Re-record every snapshot that fails during a test run',
18 | type: 'boolean',
19 | default: false,
20 | alias: 'u',
21 | },
22 |
23 | verbose: {
24 | description: 'Display individual test results with the test suite hierarchy',
25 | type: 'boolean',
26 | default: false,
27 | },
28 |
29 | watch: {
30 | description: 'Watch files for changes and rerun tests related to changed files',
31 | type: 'boolean',
32 | default: false,
33 | },
34 |
35 | debug: {
36 | description: 'Run tests in debug mode (https://jestjs.io/docs/en/troubleshooting)',
37 | type: 'boolean',
38 | default: false,
39 | },
40 |
41 | skipApiVersionCheck: {
42 | description: 'Deprecated: this noop flag is kept for backward compatibility',
43 | type: 'boolean',
44 | },
45 | };
46 |
47 | module.exports = testOptions;
48 |
--------------------------------------------------------------------------------
/src/utils/project.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const fs = require('fs');
10 | const path = require('path');
11 | const fg = require('fast-glob');
12 |
13 | const PROJECT_ROOT = fs.realpathSync(process.cwd());
14 |
15 | let PATHS = [];
16 |
17 | function getSfdxProjectJson() {
18 | const sfdxProjectJson = path.join(PROJECT_ROOT, 'sfdx-project.json');
19 |
20 | if (!fs.existsSync(sfdxProjectJson)) {
21 | throw new Error(
22 | 'Could not find sfdx-project.json. Make sure `lwc-jest` is run from project root',
23 | );
24 | }
25 |
26 | return require(sfdxProjectJson);
27 | }
28 |
29 | // get relative path to 'lwc' directory from project root
30 | // If jest is running in watch mode, caching the paths means that new modules will not be detected which might cause tests to fail.
31 | function getModulePaths() {
32 | if (PATHS.length > 0) return PATHS;
33 | const packageDirectories = getSfdxProjectJson().packageDirectories;
34 | const projectPaths = packageDirectories.map((entry) => `${entry.path}/**/lwc`);
35 | PATHS = fg.sync(projectPaths, { onlyDirectories: true });
36 | return PATHS;
37 | }
38 |
39 | module.exports = {
40 | PROJECT_ROOT,
41 | getSfdxProjectJson,
42 | getModulePaths,
43 | };
44 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Description
2 |
3 | #### Steps to Reproduce
4 |
5 |
14 |
15 | ```js
16 | // simplified test case
17 | it('does x when y', () => {
18 | ...
19 | });
20 | ```
21 |
22 | ```html
23 |
24 | ...
25 | ```
26 |
27 | ```js
28 | // JS for component under test
29 | import { LightningElement } from 'lwc';
30 |
31 | export default class Foo extends LightningElement {
32 | ...
33 | }
34 | ```
35 |
36 | ```js
37 | // Jest config overrides (if any)
38 | const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');
39 | module.exports = {
40 | ...jestConfig,
41 | foo: 'bar',
42 | };
43 | ```
44 |
45 | ```bash
46 | # Command to repro
47 | sfdx-lwc-jest -- --no-cache
48 | ```
49 |
50 | #### Expected Results
51 |
52 |
53 |
54 | #### Actual Results
55 |
56 |
57 |
58 | ### Version
59 |
60 | - @salesforce/sfdx-lwc-jest: x.x.x
61 | - Node: x.x.x
62 |
63 | **Possible Solution**
64 |
65 |
66 |
67 | **Additional context/Screenshots**
68 |
69 |
70 |
--------------------------------------------------------------------------------
/tests/__snapshots__/help.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`--help attribute shows help 1`] = `
4 | "\`sfdx-lwc-jest [options]\` runs Jest unit tests in SFDX workspace
5 |
6 | Options:
7 | --version Show version number [boolean]
8 | --coverage Collect coverage and display in output
9 | [boolean] [default: false]
10 | -u, --updateSnapshot Re-record every snapshot that fails during a test
11 | run [boolean] [default: false]
12 | --verbose Display individual test results with the test suite
13 | hierarchy [boolean] [default: false]
14 | --watch Watch files for changes and rerun tests related to
15 | changed files [boolean] [default: false]
16 | --debug Run tests in debug mode
17 | (https://jestjs.io/docs/en/troubleshooting)
18 | [boolean] [default: false]
19 | --skipApiVersionCheck Deprecated: this noop flag is kept for backward
20 | compatibility [boolean]
21 | --help Show help [boolean]
22 |
23 | Examples:
24 | sfdx-lwc-jest --coverage Collect coverage and display in output
25 | sfdx-lwc-jest -- --json All params after \`--\` are directly passed to Jest
26 | "
27 | `;
28 |
--------------------------------------------------------------------------------
/src/lightning-stubs/platformWorkspaceApi/platformWorkspaceApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | // Mock values that are not part of the lightning/platformWorkspaceApi signature
10 | // In this default test scenario, we assume that two tabs are open, and the first one is focused
11 | export const TAB0 = 'tab0';
12 | export const TAB1 = 'tab1';
13 | export const FOCUSED_TAB_ID = TAB0;
14 | export const ENCLOSING_TAB_ID = TAB0;
15 | export const OPEN_TABS = [{ tabId: TAB0 }, { tabId: TAB1 }];
16 |
17 | // Mocked methods and wires that are part of the lightning/platformWorkspaceApi signature
18 | export const closeTab = jest.fn().mockResolvedValue(true);
19 | export const disableTabClose = jest.fn().mockResolvedValue(true);
20 | export const focusTab = jest.fn().mockResolvedValue(true);
21 | export const getAllTabInfo = jest.fn().mockResolvedValue(OPEN_TABS);
22 | export const getFocusedTabInfo = jest.fn().mockResolvedValue({ tabId: TAB0 });
23 | export const getTabInfo = jest.fn().mockResolvedValue({ tabId: TAB0 });
24 | export const openSubtab = jest.fn().mockResolvedValue(true);
25 | export const openTab = jest.fn().mockResolvedValue(true);
26 | export const refreshTab = jest.fn().mockResolvedValue(true);
27 | export const setTabIcon = jest.fn().mockResolvedValue(true);
28 | export const setTabLabel = jest.fn().mockResolvedValue(true);
29 | export const setTabHighlighted = jest.fn().mockResolvedValue(true);
30 |
31 | export const EnclosingTabId = createTestWireAdapter(jest.fn());
32 | export const IsConsoleNavigation = createTestWireAdapter(jest.fn());
33 |
--------------------------------------------------------------------------------
/src/lightning-stubs/input/input.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { LightningElement, api } from 'lwc';
8 |
9 | export default class Input extends LightningElement {
10 | @api accept;
11 | @api autocomplete;
12 | @api checked;
13 | @api dateAriaControls;
14 | @api dateAriaDescribedBy;
15 | @api dateAriaLabel;
16 | @api dateAriaLabelledBy;
17 | @api dateStyle;
18 | @api disabled;
19 | @api fieldLevelHelp;
20 | @api files;
21 | @api formatFractionDigits;
22 | @api formatter;
23 | @api isLoading;
24 | @api label;
25 | @api max;
26 | @api maxLength;
27 | @api messageToggleActive;
28 | @api messageToggleInactive;
29 | @api messageWhenBadInput;
30 | @api messageWhenPatternMismatch;
31 | @api messageWhenRangeOverflow;
32 | @api messageWhenRangeUnderflow;
33 | @api messageWhenStepMismatch;
34 | @api messageWhenTooLong;
35 | @api messageWhenTooShort;
36 | @api messageWhenTypeMismatch;
37 | @api messageWhenValueMissing;
38 | @api min;
39 | @api minLength;
40 | @api multiple;
41 | @api name;
42 | @api pattern;
43 | @api placeholder;
44 | @api readOnly;
45 | @api required;
46 | @api selectionEnd;
47 | @api selectionStart;
48 | @api step;
49 | @api timeAriaControls;
50 | @api timeAriaDescribedBy;
51 | @api timeAriaLabelledBy;
52 | @api timeStyle;
53 | @api timezone;
54 | @api type;
55 | @api validity;
56 | @api value;
57 | @api variant;
58 | @api checkValidity() {}
59 | @api reportValidity() {}
60 | @api setCustomValidity() {}
61 | @api showHelpMessageIfInvalid() {}
62 | }
63 |
--------------------------------------------------------------------------------
/src/config.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const path = require('path');
10 | const jestPreset = require('@lwc/jest-preset');
11 | const { PROJECT_ROOT, getModulePaths } = require('./utils/project.js');
12 |
13 | function getCoveragePaths() {
14 | const modulePaths = getModulePaths();
15 | return modulePaths
16 | .map((p) => {
17 | // convert back to forward slashes here on Windows for Jest to be happy
18 | const prefix = p.replace(/\\/g, '/');
19 | return [
20 | // Note no `*.js` here - Jest will not find `.js` files unless you use a bare `*`
21 | prefix + '/**/*',
22 | // Specifically exclude HTML/CSS files since Jest doesn't understand the syntax
23 | '!' + prefix + '/**/*.html',
24 | '!' + prefix + '/**/*.css',
25 | ];
26 | })
27 | .flat();
28 | }
29 |
30 | const jestConfig = {
31 | // Inherited from @lwc/jest-preset
32 | moduleFileExtensions: jestPreset.moduleFileExtensions || ['ts', 'js', 'html'],
33 | testEnvironment: jestPreset.testEnvironment || 'jsdom',
34 | transform: {
35 | ...jestPreset.transform,
36 | '^.+\\.(js|ts|html|css)$': require.resolve('@lwc/jest-transformer'),
37 | },
38 | setupFilesAfterEnv: jestPreset.setupFilesAfterEnv || [],
39 | snapshotSerializers: jestPreset.snapshotSerializers || [
40 | require.resolve('@lwc/jest-serializer'),
41 | ],
42 | // Specific to sfdx-lwc-jest
43 | collectCoverageFrom: getCoveragePaths(),
44 | resolver: path.join(__dirname, './resolver.js'),
45 | rootDir: PROJECT_ROOT,
46 | testPathIgnorePatterns: ['/node_modules/', '/test/specs/'],
47 | transformIgnorePatterns: [
48 | '/node_modules/(?!(.*@salesforce/sfdx-lwc-jest/src/lightning-stubs)/)',
49 | ],
50 | };
51 |
52 | module.exports = { jestConfig };
53 |
--------------------------------------------------------------------------------
/eslint.config.mjs:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'eslint/config';
2 | import js from '@eslint/js';
3 | import globals from 'globals';
4 | import header from 'eslint-plugin-header';
5 | import babelParser from '@babel/eslint-parser';
6 |
7 | // Workaround for plugin schema validation failing in eslint v9
8 | // Ref: https://github.com/Stuk/eslint-plugin-header/issues/57#issuecomment-2378485611
9 | header.rules.header.meta.schema = false;
10 |
11 | export default defineConfig([
12 | js.configs.recommended,
13 | {
14 | languageOptions: {
15 | globals: {
16 | ...globals.node,
17 | ...globals.jest,
18 | },
19 | },
20 | plugins: { header },
21 | rules: {
22 | 'header/header': [
23 | 'error',
24 | 'block',
25 | [
26 | '',
27 | {
28 | pattern:
29 | '^ \\* Copyright \\(c\\) \\d{4}, ([sS]alesforce.com, inc|Salesforce, Inc)\\.$',
30 | // This copyright text should match the text used in the rollup config
31 | template: ` * Copyright (c) ${new Date().getFullYear()}, Salesforce, Inc.`,
32 | },
33 | ' * All rights reserved.',
34 | ' * SPDX-License-Identifier: MIT',
35 | ' * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT',
36 | ' ',
37 | ],
38 | 1 /* newline after header */,
39 | ],
40 | },
41 | },
42 | {
43 | files: ['src/lightning-stubs/**'],
44 | languageOptions: {
45 | globals: { ...globals.browser },
46 | sourceType: 'module',
47 | // Use babel parser for decorator support
48 | parser: babelParser,
49 | parserOptions: {
50 | requireConfigFile: false,
51 | babelOptions: {
52 | plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]],
53 | },
54 | },
55 | },
56 | },
57 | ]);
58 |
--------------------------------------------------------------------------------
/src/resolver.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const fs = require('fs');
10 | const path = require('path');
11 | const lwcResolver = require('@lwc/jest-resolver');
12 |
13 | const { PROJECT_ROOT, getModulePaths } = require('./utils/project.js');
14 |
15 | const { getInfoFromId } = require('./utils/module.js');
16 |
17 | const DEFAULT_NAMESPACE = 'c';
18 |
19 | function isFile(file) {
20 | let result;
21 |
22 | try {
23 | const stat = fs.statSync(file);
24 | result = stat.isFile() || stat.isFIFO();
25 | } catch (e) {
26 | if (!(e && e.code === 'ENOENT')) {
27 | throw e;
28 | }
29 | result = false;
30 | }
31 |
32 | return result;
33 | }
34 |
35 | function resolveAsFile(name, extensions) {
36 | if (isFile(name)) {
37 | return name;
38 | }
39 |
40 | for (let i = 0; i < extensions.length; i++) {
41 | const file = name + extensions[i];
42 | if (isFile(file)) {
43 | return file;
44 | }
45 | }
46 |
47 | return undefined;
48 | }
49 |
50 | function getLightningMock(modulePath) {
51 | const p = path.join(__dirname, 'lightning-stubs', modulePath);
52 | if (fs.existsSync(p)) {
53 | return path.join(p, modulePath + '.js');
54 | }
55 | }
56 |
57 | function getModule(modulePath, options) {
58 | const { ns, name } = getInfoFromId(modulePath);
59 |
60 | if (ns === 'lightning') {
61 | return getLightningMock(name);
62 | }
63 |
64 | if (ns === DEFAULT_NAMESPACE) {
65 | const paths = getModulePaths();
66 | for (let i = 0; i < paths.length; i++) {
67 | const file = resolveAsFile(
68 | path.join(PROJECT_ROOT, paths[i], name, name),
69 | options.extensions,
70 | );
71 | if (file) {
72 | return fs.realpathSync(file);
73 | }
74 | }
75 | }
76 | }
77 |
78 | module.exports = function (modulePath, options) {
79 | if (modulePath === 'lwc') {
80 | return require.resolve('@lwc/engine-dom');
81 | }
82 | return getModule(modulePath, options) || lwcResolver.apply(null, arguments);
83 | };
84 |
--------------------------------------------------------------------------------
/tests/test-runner.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const child_process = require('child_process');
10 | const runJest = require('../src/utils/test-runner');
11 |
12 | jest.mock('child_process');
13 | jest.mock('../src/log');
14 | jest.mock('../src/utils/project');
15 |
16 | beforeEach(() => {
17 | child_process.spawn.mockReset();
18 |
19 | child_process.spawn.mockImplementation(() => {
20 | return {
21 | on(name, cb) {
22 | if (name === 'close') cb(0);
23 | },
24 | };
25 | });
26 | });
27 |
28 | test('invokes node executable with jest path', async () => {
29 | await runJest({ _: [] });
30 | const [[cmd, args]] = child_process.spawn.mock.calls;
31 |
32 | expect(cmd).toContain('node');
33 | expect(args[0]).toMatch(/bin\/jest\.js$/);
34 | });
35 |
36 | test('invokes jest with --runInBand and --inspect-brk in debug mode', async () => {
37 | await runJest({ debug: true, _: [] });
38 | const [[, args]] = child_process.spawn.mock.calls;
39 |
40 | expect(args).toContain('--inspect-brk');
41 | expect(args).toContain('--runInBand');
42 | });
43 |
44 | test.each(['coverage', 'updateSnapshot', 'verbose', 'watch'])(
45 | 'invokes jest with option %s when present',
46 | async (option) => {
47 | await runJest({ [option]: true, _: [] });
48 | const [[, args]] = child_process.spawn.mock.calls;
49 |
50 | expect(args).toContain(`--${option}`);
51 | },
52 | );
53 |
54 | test('invokes jest with position arguments when present', async () => {
55 | await runJest({ _: ['--showConfig', 'my/test.js'] });
56 | const [[, args]] = child_process.spawn.mock.calls;
57 |
58 | expect(args).toContain(`--showConfig`);
59 | expect(args).toContain(`my/test.js`);
60 | });
61 |
62 | test('resolves with jest command exit code', async () => {
63 | const EXIT_CODE = 42;
64 | child_process.spawn.mockImplementation(() => {
65 | return {
66 | on(name, cb) {
67 | if (name === 'close') {
68 | cb(EXIT_CODE);
69 | }
70 | },
71 | };
72 | });
73 |
74 | const res = await runJest({ _: [] });
75 | expect(res).toBe(EXIT_CODE);
76 | });
77 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@salesforce/sfdx-lwc-jest",
3 | "version": "7.5.0",
4 | "description": "Run Jest against LWC components in a Salesforce DX workspace environment",
5 | "main": "src/index.js",
6 | "license": "MIT",
7 | "files": [
8 | "bin/",
9 | "src/",
10 | "config.js"
11 | ],
12 | "repository": {
13 | "type": "git",
14 | "url": "https://github.com/salesforce/sfdx-lwc-jest.git"
15 | },
16 | "bugs": {
17 | "url": "https://github.com/salesforce/sfdx-lwc-jest/issues"
18 | },
19 | "homepage": "https://github.com/salesforce/sfdx-lwc-jest#readme",
20 | "bin": {
21 | "lwc-jest": "./bin/sfdx-lwc-jest",
22 | "sfdx-lwc-jest": "./bin/sfdx-lwc-jest"
23 | },
24 | "scripts": {
25 | "prepare": "husky install",
26 | "lint": "eslint src/ tests/",
27 | "format": "prettier --write '**/*.{js,json,md,html,css}'",
28 | "format:check": "prettier --check '**/*.{js,json,md,html,css}'",
29 | "release": "yarn release:publish",
30 | "release:version": "npm version",
31 | "release:publish": "npm publish --access public --registry=https://registry.npmjs.org",
32 | "test": "jest"
33 | },
34 | "dependencies": {
35 | "@lwc/compiler": "8.26.1",
36 | "@lwc/engine-dom": "8.26.1",
37 | "@lwc/engine-server": "8.26.1",
38 | "@lwc/jest-preset": "19.1.2",
39 | "@lwc/jest-resolver": "19.1.2",
40 | "@lwc/jest-serializer": "19.1.2",
41 | "@lwc/jest-transformer": "19.1.2",
42 | "@lwc/module-resolver": "8.26.1",
43 | "@lwc/synthetic-shadow": "8.26.1",
44 | "@lwc/wire-service": "8.26.1",
45 | "@salesforce/wire-service-jest-util": "4.1.5",
46 | "fast-glob": "^3.3.3",
47 | "jest": "29.7.0",
48 | "jest-environment-jsdom": "29.7.0",
49 | "yargs": "~17.7.2"
50 | },
51 | "devDependencies": {
52 | "@babel/core": "^7.28.4",
53 | "@babel/eslint-parser": "^7.28.4",
54 | "@babel/plugin-proposal-decorators": "^7.28.0",
55 | "@eslint/eslintrc": "^3.3.1",
56 | "@eslint/js": "^9.36.0",
57 | "eslint": "^9.36.0",
58 | "eslint-plugin-header": "^3.1.1",
59 | "globals": "^16.4.0",
60 | "husky": "^9.1.7",
61 | "isbinaryfile": "^5.0.6",
62 | "lint-staged": "^16.2.3",
63 | "prettier": "^3.6.2"
64 | },
65 | "volta": {
66 | "node": "24.11.0",
67 | "yarn": "1.22.22"
68 | },
69 | "lint-staged": {
70 | "*.js": "eslint",
71 | "*.{js,json,md,html,css}": "prettier --write"
72 | },
73 | "publishConfig": {
74 | "tag": "prerelease"
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/utils/test-runner.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | 'use strict';
8 |
9 | const fs = require('fs');
10 | const path = require('path');
11 | const { spawn } = require('child_process');
12 |
13 | const { PROJECT_ROOT } = require('./project');
14 |
15 | const { info, warn } = require('../log');
16 | const { jestConfig } = require('../config');
17 |
18 | // List of CLI options that should be passthrough to jest.
19 | const JEST_PASSTHROUGH_OPTIONS = new Set(['coverage', 'updateSnapshot', 'verbose', 'watch']);
20 |
21 | function getJestPath() {
22 | const packageJsonPath = require.resolve('jest/package.json');
23 |
24 | const { bin } = require(packageJsonPath);
25 |
26 | // Account for difference in behavior between npm v6 and v7 (#221)
27 | let normalizedBinPath = bin;
28 | if (typeof bin === 'object') {
29 | normalizedBinPath = bin.jest;
30 | }
31 |
32 | return path.resolve(path.dirname(packageJsonPath), normalizedBinPath);
33 | }
34 |
35 | function getJestArgs(argv) {
36 | // Extract known options from parsed arguments
37 | const knownOptions = Object.keys(argv)
38 | .filter((key) => argv[key] && JEST_PASSTHROUGH_OPTIONS.has(key))
39 | .map((key) => `--${key}`);
40 |
41 | // Extract remaining options after `--`
42 | const rest = argv._;
43 |
44 | const jestArgs = [...knownOptions, ...rest];
45 |
46 | // Force jest to run in band when debugging.
47 | if (argv.debug) {
48 | jestArgs.unshift('--runInBand');
49 | }
50 |
51 | // Provide default configuration when none is present at the project root.
52 | const hasCustomConfig =
53 | fs.existsSync(path.resolve(PROJECT_ROOT, 'jest.config.js')) ||
54 | fs.existsSync(path.resolve(PROJECT_ROOT, 'jest.config.mjs')) ||
55 | fs.existsSync(path.resolve(PROJECT_ROOT, 'jest.config.cjs'));
56 | if (!hasCustomConfig) {
57 | jestArgs.unshift(`--config=${JSON.stringify(jestConfig)}`);
58 | }
59 |
60 | return jestArgs;
61 | }
62 |
63 | async function testRunner(argv) {
64 | if (argv.skipApiVersionCheck !== undefined) {
65 | warn(
66 | 'The --skipApiVersionCheck flag is deprecated and will be removed in future versions.',
67 | );
68 | }
69 | const spawnCommand = 'node';
70 | const spawnArgs = [getJestPath(), ...getJestArgs(argv)];
71 |
72 | if (argv.debug) {
73 | spawnArgs.unshift('--inspect-brk');
74 |
75 | info('Running in debug mode...');
76 | info(`${spawnCommand} ${spawnArgs.join(' ')}`);
77 | }
78 |
79 | return new Promise((resolve) => {
80 | const jest = spawn(spawnCommand, spawnArgs, {
81 | env: process.env,
82 | stdio: 'inherit',
83 | });
84 |
85 | jest.on('close', (code) => resolve(code));
86 | });
87 | }
88 |
89 | module.exports = testRunner;
90 |
--------------------------------------------------------------------------------
/src/lightning-stubs/analyticsWaveApi/analyticsWaveApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const createDataConnector = jest.fn();
10 | export const createDataflowJob = jest.fn();
11 | export const createDataset = jest.fn();
12 | export const createDatasetVersion = jest.fn();
13 | export const createReplicatedDataset = jest.fn();
14 | export const deleteDataConnector = jest.fn();
15 | export const deleteDataset = jest.fn();
16 | export const deleteRecipe = jest.fn();
17 | export const deleteReplicatedDataset = jest.fn();
18 | export const executeQuery = createLdsTestWireAdapter(jest.fn());
19 | export const getActions = createLdsTestWireAdapter(jest.fn());
20 | export const getAnalyticsLimits = createLdsTestWireAdapter(jest.fn());
21 | export const getDataConnector = createLdsTestWireAdapter(jest.fn());
22 | export const getDataConnectors = createLdsTestWireAdapter(jest.fn());
23 | export const getDataConnectorSourceFields = createLdsTestWireAdapter(jest.fn());
24 | export const getDataConnectorSourceObject = createLdsTestWireAdapter(jest.fn());
25 | export const getDataConnectorSourceObjectDataPreviewWithFields = createLdsTestWireAdapter(
26 | jest.fn(),
27 | );
28 | export const getDataConnectorSourceObjects = createLdsTestWireAdapter(jest.fn());
29 | export const getDataConnectorStatus = createLdsTestWireAdapter(jest.fn());
30 | export const getDataConnectorTypes = createLdsTestWireAdapter(jest.fn());
31 | export const getDataflowJob = createLdsTestWireAdapter(jest.fn());
32 | export const getDataflowJobNode = createLdsTestWireAdapter(jest.fn());
33 | export const getDataflowJobNodes = createLdsTestWireAdapter(jest.fn());
34 | export const getDataflowJobs = createLdsTestWireAdapter(jest.fn());
35 | export const getDataflows = createLdsTestWireAdapter(jest.fn());
36 | export const getDataset = createLdsTestWireAdapter(jest.fn());
37 | export const getDatasets = createLdsTestWireAdapter(jest.fn());
38 | export const getDatasetVersion = createLdsTestWireAdapter(jest.fn());
39 | export const getDatasetVersions = createLdsTestWireAdapter(jest.fn());
40 | export const getDependencies = createLdsTestWireAdapter(jest.fn());
41 | export const getRecipe = createLdsTestWireAdapter(jest.fn());
42 | export const getRecipeNotification = createLdsTestWireAdapter(jest.fn());
43 | export const getRecipes = createLdsTestWireAdapter(jest.fn());
44 | export const getReplicatedDataset = createLdsTestWireAdapter(jest.fn());
45 | export const getReplicatedDatasets = createLdsTestWireAdapter(jest.fn());
46 | export const getReplicatedFields = createLdsTestWireAdapter(jest.fn());
47 | export const getSchedule = createLdsTestWireAdapter(jest.fn());
48 | export const getSecurityCoverageDatasetVersion = createLdsTestWireAdapter(jest.fn());
49 | export const getWaveFolders = createLdsTestWireAdapter(jest.fn());
50 | export const getWaveTemplate = createLdsTestWireAdapter(jest.fn());
51 | export const getWaveTemplateConfig = createLdsTestWireAdapter(jest.fn());
52 | export const getWaveTemplateReleaseNotes = createLdsTestWireAdapter(jest.fn());
53 | export const getWaveTemplates = createLdsTestWireAdapter(jest.fn());
54 | export const getXmd = createLdsTestWireAdapter(jest.fn());
55 | export const ingestDataConnector = jest.fn();
56 | export const updateDataConnector = jest.fn();
57 | export const updateDataflowJob = jest.fn();
58 | export const updateDataset = jest.fn();
59 | export const updateDatasetVersion = jest.fn();
60 | export const updateRecipe = jest.fn();
61 | export const updateRecipeNotification = jest.fn();
62 | export const updateReplicatedDataset = jest.fn();
63 | export const updateReplicatedFields = jest.fn();
64 | export const updateSchedule = jest.fn();
65 | export const updateXmd = jest.fn();
66 |
--------------------------------------------------------------------------------
/src/lightning-stubs/uiRecordApi/uiRecordApi.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, salesforce.com, inc.
3 | * All rights reserved.
4 | * SPDX-License-Identifier: MIT
5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 | */
7 | import { createLdsTestWireAdapter } from '@salesforce/wire-service-jest-util';
8 |
9 | export const getRecord = createLdsTestWireAdapter(jest.fn());
10 | export const getRecords = createLdsTestWireAdapter(jest.fn());
11 | export const getRecordCreateDefaults = createLdsTestWireAdapter(jest.fn());
12 | export const updateRecord = jest.fn().mockResolvedValue({});
13 | export const createRecord = jest.fn().mockResolvedValue({});
14 | export const deleteRecord = jest.fn().mockResolvedValue();
15 | export const generateRecordInputForCreate = jest.fn();
16 | export const generateRecordInputForUpdate = jest.fn();
17 | export const createRecordInputFilteredByEditedFields = jest.fn();
18 | export const getRecordInput = jest.fn();
19 | export const getRecordNotifyChange = createLdsTestWireAdapter(jest.fn());
20 | export const refresh = jest.fn().mockResolvedValue();
21 | export const getRecordUi = createLdsTestWireAdapter(jest.fn());
22 | export const notifyRecordUpdateAvailable = jest.fn().mockResolvedValue();
23 |
24 | /**
25 | * Gets a field's value from a record.
26 | * @param record The record.
27 | * @param field The qualified API name of the field to return.
28 | * @returns The field's value (which may be a record in the case of spanning fields), or undefined if the field isn't found.
29 | */
30 | export const getFieldValue = jest.fn((record, field) => {
31 | const unqualifiedField = splitQualifiedFieldApiName(getFieldApiName(field))[1];
32 | const fields = unqualifiedField.split('.');
33 | let r = record;
34 | while (fields.length > 0 && r && r.fields) {
35 | const f = fields.shift();
36 | const fvr = r.fields[f];
37 | if (fvr === undefined) {
38 | return undefined;
39 | } else {
40 | r = fvr.value;
41 | }
42 | }
43 | return r;
44 | });
45 |
46 | /**
47 | * Gets a field's display value from a record.
48 | * @param record The record.
49 | * @param field The qualified API name of the field to return.
50 | * @returns The field's display value, or undefined if the field isn't found.
51 | */
52 | export const getFieldDisplayValue = jest.fn((record, field) => {
53 | const unqualifiedField = splitQualifiedFieldApiName(getFieldApiName(field))[1];
54 | const fields = unqualifiedField.split('.');
55 | let r = record;
56 | while (r && r.fields) {
57 | const f = fields.shift();
58 | const fvr = r.fields[f];
59 | if (fvr === undefined) {
60 | return undefined;
61 | } else if (fields.length > 0) {
62 | r = fvr.value;
63 | } else {
64 | return fvr.displayValue;
65 | }
66 | }
67 | return r;
68 | });
69 |
70 | /**
71 | * Returns the field API name, qualified with an object name if possible.
72 | * @param value The value from which to get the qualified field API name.
73 | * @return The qualified field API name.
74 | */
75 | function getFieldApiName(value) {
76 | if (typeof value === 'string') {
77 | return value;
78 | } else if (
79 | value &&
80 | typeof value.objectApiName === 'string' &&
81 | typeof value.fieldApiName === 'string'
82 | ) {
83 | return value.objectApiName + '.' + value.fieldApiName;
84 | }
85 | throw new TypeError('Value is not a string or FieldId.');
86 | }
87 |
88 | /**
89 | * Split the object API name and field API name from a qualified field name.
90 | * Eg: Opportunity.Title returns ['Opportunity', 'Title']
91 | * Eg: Opportunity.Account.Name returns ['Opportunity', 'Account.Name']
92 | * @param fieldApiName The qualified field name.
93 | * @return The object and field API names.
94 | */
95 | function splitQualifiedFieldApiName(fieldApiName) {
96 | const idx = fieldApiName.indexOf('.');
97 | if (idx < 1) {
98 | // object api name must non-empty
99 | throw new TypeError('Value does not include an object API name.');
100 | }
101 | return [fieldApiName.substring(0, idx), fieldApiName.substring(idx + 1)];
102 | }
103 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | Newer release notes can be found in [GitHub Releases](https://github.com/salesforce/sfdx-lwc-jest/releases).
4 |
5 | ## 0.7.1 (March 3, 2020)
6 |
7 | ## Fixes
8 |
9 | - Update a variety of stubs, including adding missing `empApi` and `pageReferenceUtils` libraries [#134](https://github.com/salesforce/sfdx-lwc-jest/pull/134)
10 | - Add `selectedItem` attribute to `` stub [#126](https://github.com/salesforce/sfdx-lwc-jest/pull/126)
11 | - Add missing `` stub [#132](https://github.com/salesforce/sfdx-lwc-jest/pull/132)
12 |
13 | ## Chores
14 |
15 | - Add code formatting and linting on all files [#135](https://github.com/salesforce/sfdx-lwc-jest/pull/135)
16 |
17 | ## 0.7.0 (January 22, 2020)
18 |
19 | ## Fixes
20 |
21 | - Fix null exit code in jest process exit [#120](https://github.com/salesforce/sfdx-lwc-jest/pull/120)
22 |
23 | ## Chores
24 |
25 | - Upgrade LWC to version 1.1.13-224.4
26 |
27 | ## 0.6.2 (November 25, 2019)
28 |
29 | ## Fixes
30 |
31 | - Add missing `required` property to `` [#114](https://github.com/salesforce/sfdx-lwc-jest/pull/114)
32 |
33 | ## Chores
34 |
35 | - Upgrade `dependencies` and `devDependencies` [#112](https://github.com/salesforce/sfdx-lwc-jest/pull/112)
36 | - Update bin reference. The `sfdx-lwc-jest` package will now expose 2 aliases `sfdx-lwc-jest` and `lwc-jest` (legacy binary name) pointing to the same executable file. [#100](https://github.com/salesforce/sfdx-lwc-jest/pull/100)
37 |
38 | ## 0.6.1 (October 16, 2019)
39 |
40 | ## Fixes
41 |
42 | - Add missing `dateStyle` and `timeStyle` properties to `` [#94](https://github.com/salesforce/sfdx-lwc-jest/pull/94)
43 | - Add missing `autocomplete` property to `` [#92](https://github.com/salesforce/sfdx-lwc-jest/pull/92)
44 |
45 | ## Chores
46 |
47 | - Upgrade `lwc` related packages to the latest version [#100](https://github.com/salesforce/sfdx-lwc-jest/pull/100)
48 |
49 | ## 0.5.3 (August 8, 2019)
50 |
51 | ## Chores
52 |
53 | - Rename package to `@salesforce/sfdx-lwc-jest` to match project name [#86](https://github.com/salesforce/sfdx-lwc-jest/pull/86)
54 |
55 | ## 0.5.2 (August 7, 2019)
56 |
57 | ## Features
58 |
59 | - Add real implementation to `getFieldValue` and `getFieldDisplayValue` [#83](https://github.com/salesforce/sfdx-lwc-jest/pull/83)
60 |
61 | ## Fixes
62 |
63 | - Add missing `tooltip` and `density` properties to stubs [#81](https://github.com/salesforce/sfdx-lwc-jest/pull/81)
64 | - Add missing `variant` property to `` [#74](https://github.com/salesforce/sfdx-lwc-jest/pull/74)
65 | - Update code coverage paths so coverage is properly reported on Windows [#72](https://github.com/salesforce/sfdx-lwc-jest/pull/72)
66 |
67 | ## Chores
68 |
69 | - Upgrade `js-yaml` dependency to address security alert [#82](https://github.com/salesforce/sfdx-lwc-jest/pull/82)
70 | - Upgrade `lodash` dependency to address security alert [#78](https://github.com/salesforce/sfdx-lwc-jest/pull/78)
71 |
72 | ## 0.5.1 (June 18, 2019)
73 |
74 | ### Fixes
75 |
76 | - Add `title` property back to the `` stub ([#69](https://github.com/salesforce/lwc-jest/pull/69))
77 |
78 | ### Chores
79 |
80 | - Upgrade LWC to version 0.37.4-220.2, removes `deasync` dependency :tada:
81 |
82 | ## 0.5.0 (May 13, 2019)
83 |
84 | ### Fixes
85 |
86 | - `platformResourceLoader` mock returns resolved Promise again
87 |
88 | ### Chores
89 |
90 | - Upgrade LWC to version 0.37.4
91 | - Expected API version check bumped to version 46.0 to match next major release
92 | - Upgrade Jest to version 24.8.0
93 |
94 | ## 0.4.14 (May 7, 2019)
95 |
96 | ### Fixes
97 |
98 | - Add missing `disabled` property to buttons components ([#54](https://github.com/salesforce/lwc-jest/pull/54))
99 |
100 | ### Chores
101 |
102 | - Remove old mock generation logic, rename mocks --> stubs ([#53](https://github.com/salesforce/lwc-jest/pull/53))
103 |
104 | ## 0.4.13 (May 2, 2019)
105 |
106 | ### Fixes
107 |
108 | - Update significant number of `lightning` stubs based on new generation script ([#50](https://github.com/salesforce/lwc-jest/pull/50))
109 | - Add `type` prop to `` stub ([#48](https://github.com/salesforce/lwc-jest/pull/48))
110 | - Add `formatFractionDigits` prop to `` stub ([#47](https://github.com/salesforce/lwc-jest/pull/47))
111 |
112 | ### Chores
113 |
114 | - Upgrade LWC to version 0.34.8 ([#44](https://github.com/salesforce/lwc-jest/pull/44))
115 | - Update README with additional troubleshooting info on deasync ([#43](https://github.com/salesforce/lwc-jest/pull/43) [#49](https://github.com/salesforce/lwc-jest/pull/49))
116 |
117 | ## 0.4.12 (March 11, 2019)
118 |
119 | ### Fixes
120 |
121 | - `lightning/platformResourceLoader` mock APIs to return a resolved Promise ([#38](https://github.com/salesforce/lwc-jest/pull/38))
122 |
123 | ### Chores
124 |
125 | - Upgrade LWC to version 0.34.7
126 |
127 | ## 0.4.11 (March 8, 2019)
128 |
129 | ### Fixes
130 |
131 | - Set `process.env.NODE_ENV` to 'test' if unset for non-debug mode ([#34](https://github.com/salesforce/lwc-jest/pull/34))
132 | - Fix code coverage option and remove `testURL` config ([#32](https://github.com/salesforce/lwc-jest/pull/32))
133 | - Fix custom namespace resolution logic ([#30](https://github.com/salesforce/lwc-jest/pull/30))
134 | - Add missing functions to `` mock ([#22](https://github.com/salesforce/lwc-jest/pull/22))
135 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Salesforce Open Source Community Code of Conduct
2 |
3 | ## About the Code of Conduct
4 |
5 | Equality is a core value at Salesforce. We believe a diverse and inclusive
6 | community fosters innovation and creativity, and are committed to building a
7 | culture where everyone feels included.
8 |
9 | Salesforce open-source projects are committed to providing a friendly, safe, and
10 | welcoming environment for all, regardless of gender identity and expression,
11 | sexual orientation, disability, physical appearance, body size, ethnicity, nationality,
12 | race, age, religion, level of experience, education, socioeconomic status, or
13 | other similar personal characteristics.
14 |
15 | The goal of this code of conduct is to specify a baseline standard of behavior so
16 | that people with different social values and communication styles can work
17 | together effectively, productively, and respectfully in our open source community.
18 | It also establishes a mechanism for reporting issues and resolving conflicts.
19 |
20 | All questions and reports of abusive, harassing, or otherwise unacceptable behavior
21 | in a Salesforce open-source project may be reported by contacting the Salesforce
22 | Open Source Conduct Committee at ossconduct@salesforce.com.
23 |
24 | ## Our Pledge
25 |
26 | In the interest of fostering an open and welcoming environment, we as
27 | contributors and maintainers pledge to making participation in our project and
28 | our community a harassment-free experience for everyone, regardless of gender
29 | identity and expression, sexual orientation, disability, physical appearance,
30 | body size, ethnicity, nationality, race, age, religion, level of experience, education,
31 | socioeconomic status, or other similar personal characteristics.
32 |
33 | ## Our Standards
34 |
35 | Examples of behavior that contributes to creating a positive environment
36 | include:
37 |
38 | - Using welcoming and inclusive language
39 | - Being respectful of differing viewpoints and experiences
40 | - Gracefully accepting constructive criticism
41 | - Focusing on what is best for the community
42 | - Showing empathy toward other community members
43 |
44 | Examples of unacceptable behavior by participants include:
45 |
46 | - The use of sexualized language or imagery and unwelcome sexual attention or
47 | advances
48 | - Personal attacks, insulting/derogatory comments, or trolling
49 | - Public or private harassment
50 | - Publishing, or threatening to publish, others' private information—such as
51 | a physical or electronic address—without explicit permission
52 | - Other conduct which could reasonably be considered inappropriate in a
53 | professional setting
54 | - Advocating for or encouraging any of the above behaviors
55 |
56 | ## Our Responsibilities
57 |
58 | Project maintainers are responsible for clarifying the standards of acceptable
59 | behavior and are expected to take appropriate and fair corrective action in
60 | response to any instances of unacceptable behavior.
61 |
62 | Project maintainers have the right and responsibility to remove, edit, or
63 | reject comments, commits, code, wiki edits, issues, and other contributions
64 | that are not aligned with this Code of Conduct, or to ban temporarily or
65 | permanently any contributor for other behaviors that they deem inappropriate,
66 | threatening, offensive, or harmful.
67 |
68 | ## Scope
69 |
70 | This Code of Conduct applies both within project spaces and in public spaces
71 | when an individual is representing the project or its community. Examples of
72 | representing a project or community include using an official project email
73 | address, posting via an official social media account, or acting as an appointed
74 | representative at an online or offline event. Representation of a project may be
75 | further defined and clarified by project maintainers.
76 |
77 | ## Enforcement
78 |
79 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
80 | reported by contacting the Salesforce Open Source Conduct Committee
81 | at ossconduct@salesforce.com. All complaints will be reviewed and investigated
82 | and will result in a response that is deemed necessary and appropriate to the
83 | circumstances. The committee is obligated to maintain confidentiality with
84 | regard to the reporter of an incident. Further details of specific enforcement
85 | policies may be posted separately.
86 |
87 | Project maintainers who do not follow or enforce the Code of Conduct in good
88 | faith may face temporary or permanent repercussions as determined by other
89 | members of the project's leadership and the Salesforce Open Source Conduct
90 | Committee.
91 |
92 | ## Attribution
93 |
94 | This Code of Conduct is adapted from the [Contributor Covenant][contributor-covenant-home],
95 | version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html.
96 | It includes adaptions and additions from [Go Community Code of Conduct][golang-coc],
97 | [CNCF Code of Conduct][cncf-coc], and [Microsoft Open Source Code of Conduct][microsoft-coc].
98 |
99 | This Code of Conduct is licensed under the [Creative Commons Attribution 3.0 License][cc-by-3-us].
100 |
101 | [contributor-covenant-home]: https://www.contributor-covenant.org 'https://www.contributor-covenant.org/'
102 | [golang-coc]: https://golang.org/conduct
103 | [cncf-coc]: https://github.com/cncf/foundation/blob/master/code-of-conduct.md
104 | [microsoft-coc]: https://opensource.microsoft.com/codeofconduct/
105 | [cc-by-3-us]: https://creativecommons.org/licenses/by/3.0/us/
106 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # @salesforce/sfdx-lwc-jest
2 |
3 | Run Jest against Lightning web components in a Salesforce DX workspace environment.
4 |
5 | ## Versions
6 |
7 | To test against the latest Salesforce production instances, use the npm tag appropriate for the current release, e.g.:
8 |
9 | ```
10 | yarn add -D @salesforce/sfdx-lwc-jest@winter22
11 | yarn add -D @salesforce/sfdx-lwc-jest@spring22
12 | ```
13 |
14 | The npm `latest` tag corresponds to the latest version of this repo, not necessarily Salesforce production versions.
15 |
16 | To see a full list of available versions, and the tag that maps to the corresponding Salesforce release, see [the list of `npm` package versions](https://www.npmjs.com/package/@salesforce/sfdx-lwc-jest?activeTab=versions).
17 |
18 | ## Installation
19 |
20 | Add this project as a devDependency:
21 |
22 | ```bash
23 | yarn add -D @salesforce/sfdx-lwc-jest
24 | ```
25 |
26 | Update your project's unit testing script in `package.json` to execute `sfdx-lwc-jest`:
27 |
28 | ```json
29 | {
30 | "scripts": {
31 | "test:unit": "sfdx-lwc-jest",
32 | "test:unit:watch": "sfdx-lwc-jest --watch",
33 | "test:unit:debug": "sfdx-lwc-jest --debug",
34 | "test:unit:coverage": "sfdx-lwc-jest --coverage"
35 | }
36 | }
37 | ```
38 |
39 | `test:unit` runs all your tests. `test:unit:watch` and `test:unit:debug` run Jest in watch and debug mode (see below).
40 |
41 | Alternatively, you can globally install the package and run directly from the command line.
42 |
43 | ## Usage
44 |
45 | ```
46 | `sfdx-lwc-jest [options]` runs Jest unit tests in SFDX workspace
47 |
48 | Options:
49 | --version Show version number [boolean]
50 | --coverage Collect coverage and display in output
51 | [boolean] [default: false]
52 | -u, --updateSnapshot Re-record every snapshot that fails during a test
53 | run [boolean] [default: false]
54 | --verbose Display individual test results with the test suite
55 | hierarchy [boolean] [default: false]
56 | --watch Watch files for changes and rerun tests related to
57 | changed files [boolean] [default: false]
58 | --debug Run tests in debug mode
59 | (https://jestjs.io/docs/en/troubleshooting)
60 | [boolean] [default: false]
61 | --help Show help [boolean]
62 |
63 | Examples:
64 | sfdx-lwc-jest --coverage Collect coverage and display in output
65 | sfdx-lwc-jest -- --json All params after `--` are directly passed to Jest
66 | ```
67 |
68 | ## Passing Additional Jest CLI Options
69 |
70 | To pass any additional Jest CLI options to your run, pass them after the `--` flag. All CLI parameters after the flag are passed directly to Jest.
71 |
72 | ```bash
73 | sfdx-lwc-jest -- --json
74 | ```
75 |
76 | See the [Jest documentation](http://facebook.github.io/jest/docs/en/cli.html) for all CLI options.
77 |
78 | ## Debug Mode
79 |
80 | Debug mode lets you easily debug your Jest tests.
81 |
82 | - Put a `debugger;` into your code
83 | - Open `chrome://inspect`
84 | - Run `sfdx-lwc-jest` with the `--debug` flag.
85 |
86 | Pass other parameters to Jest after the `--` flag. For example,
87 |
88 | ```bash
89 | sfdx-lwc-jest --debug -- --no-cache
90 | ```
91 |
92 | ### Debugging in Visual Studio Code
93 |
94 | If you prefer to debug inside Visual Studio Code, follow these steps:
95 |
96 | - From the Visual Studio Code dropdowns, select Debug > Add Configuration....
97 | - If you're prompted for an Environment choose any value.
98 | - Mac users, replace the contents of the generated `launch.json` with the following. (for Windows users see the [Jest website](https://jestjs.io/docs/en/troubleshooting#debugging-in-vs-code) for launch.json contents).
99 |
100 | ```json
101 | {
102 | "version": "0.2.0",
103 | "configurations": [
104 | {
105 | "name": "Debug Jest Tests",
106 | "type": "node",
107 | "request": "launch",
108 | "runtimeArgs": [
109 | "--inspect-brk",
110 | "${workspaceRoot}/node_modules/.bin/jest",
111 | "--runInBand"
112 | ],
113 | "console": "integratedTerminal",
114 | "internalConsoleOptions": "neverOpen",
115 | "port": 9229
116 | }
117 | ]
118 | }
119 | ```
120 |
121 | - Add a `jest.config.js` file to the root of the Salesforce DX project as described [here](#overriding-jest-config). You must add this file to run Jest from Visual Studio Code.
122 | - To run tests, press F5 or select Debug > Start Debugging.
123 |
124 | ## Watch Mode
125 |
126 | Watch mode causes Jest to monitor files for changes and rerun tests related to the changed files. This is a great way to rapidly make component and test changes while monitoring tests results.
127 |
128 | ## Overriding Jest Config
129 |
130 | `sfdx-lwc-jest` sets up all the necessary Jest [configs](http://facebook.github.io/jest/docs/en/configuration.html) for you to run tests out of the box without any additional changes. To override any options or set additional ones, create a file called `jest.config.js` at the root of your Salesforce DX project, import the default config from `sfdx-lwc-jest`, modify as you please, and then export the new config.
131 |
132 | ```js
133 | const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');
134 | module.exports = {
135 | ...jestConfig,
136 | // add any custom configurations here
137 | };
138 | ```
139 |
140 | ## Resolving External Lightning Web Components
141 |
142 | If a Lightning web component isn't located in the local `lwc` directory of your Salesforce DX project, you must mock it in your Jest tests. This package includes a set of stubs for all components in the `lightning` namespace.
143 |
144 | ### Lightning Namespaced Component Stubs
145 |
146 | This package installs stubs for the `lightning` base components to the `src/lightning-stubs` directory. These stubs are used automatically when running tests through `sfdx-lwc-jest`. To override the default stub provided for your project, override the `moduleNameMapper` config as described in [Other Component Mocks](#other-component-mocks).
147 |
148 | ### Other Component Mocks
149 |
150 | For components from other namespaces, not in your local `lwc` directory, create your own mock and update the Jest config to map the name of these components to the mock file.
151 |
152 | Let's go through an example. We want to test the following template, `helloWorld.html`.
153 |
154 | ```html
155 |
156 | Hello From a Lightning Web Component!
157 |
158 |
159 |
160 | ```
161 |
162 | Because it's in the `lightning` namespace, the `lightning-button` just works. However, you must write some code to help the Jest resolver find the `foo-fancy-button` component. First, create a `jest.config.js` file at the root of the Salesforce DX project workspace and add the following:
163 |
164 | ```js
165 | const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');
166 | module.exports = {
167 | ...jestConfig,
168 | moduleNameMapper: {
169 | '^foo/fancyButton$': '/force-app/test/jest-mocks/foo/fancyButton',
170 | },
171 | };
172 | ```
173 |
174 | This config tells Jest to map the import for `foo-fancy-button` to the provided file. Notice that the first dash is converted to a forward slash and the rest of the component name goes from kebab to camel case. The reason for the forward slash is because the module resolver treats everything before the first dash as the namespace. Here, `` maps to the root of the Salesforce DX workspace. Note that this file location is not required, just an example.
175 |
176 | You also have the freedom to make these mock implementations as sophisticated or simple as you'd like. In this example, we'll keep `foo-fancy-button` simple with an empty template and no functionality in the `.js` file, but you can always add whatever markup you'd like or implement functionality like any other Lightning web component.
177 |
178 | Finally, we need to create the mock `foo-fancy-button` files. In the `force-app/test/jest-mocks/foo` directory create the following files:
179 |
180 | ```html
181 |
182 |
183 | ```
184 |
185 | ```js
186 | // fancyButton.js
187 | import { LightningElement, api } from 'lwc';
188 | export default class FancyButton extends LightningElement {
189 | @api label;
190 | // any other implementation you may want to expose here
191 | }
192 | ```
193 |
194 | ## Testing @wire Adapters
195 |
196 | To provision data through `@wire` adapters in unit tests, use the APIs provided by [`@salesforce/wire-service-jest-util`](https://github.com/salesforce/wire-service-jest-util). These APIs are exposed through this package so you do not need to include another dependency in your package.json.
197 |
198 | See the `@salesforce/wire-service-jest-util` [README](https://github.com/salesforce/wire-service-jest-util/blob/master/README.md) for further documentation on these APIs.
199 |
--------------------------------------------------------------------------------