You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm testing using registerApexTestWireAdapter @wire adapter.
It runs fine if the test is launched from the Powershell. Also, it runs as expected if I launch it using the "Debug Test" option from VSC (Salesforce Extension Pack) See https://developer.salesforce.com/tools/vscode/en/lwc/testing
But if I use the "Run Test" option then DOM is not refreshed after emit() commands in Promise.resolve().then block and the test is failed.
All other tests without egisterApexTestWireAdapter @wire adapter are running fine from the VSC (Salesforce Extension Pack).
I also noticed that the error reproduced if I run the test from CMD but not from Powershell. When I run the test in Powershell it opens CMD during the execution but this time it works as expected. (Test marked green and the correct json created in C:\Users\bunig\Dev\sfdc\KPIManagement\kpimanagement.sfdx\tools\testresults\lwc)
Steps to Reproduce
Create a test that uses registerApexTestWireAdapter @wire adapter.
it('renders records when data returned',()=>{// Create initial elementconstelement=createElement('c-main-kpi-set',{is: MainKpiSet});document.body.appendChild(element);getKPISetListAdapter.emit(mockGetKPISetList);returnPromise.resolve().then(()=>{constdetailEls=element.shadowRoot.querySelectorAll('lightning-vertical-navigation-item');expect(detailEls.length).toBe(mockGetKPISetList.length);expect(detailEls[0].label).toBe(mockGetKPISetList[0].Name);});});
<!-- HTML for component under test --><lightning-vertical-navigationcompactselected-item={selectedKpiSetId}onselect={handleSelectKPISet}data-id="navset"><lightning-vertical-navigation-section><templateif:true={KPISet}><templatefor:each={KPISet}for:item="row"><lightning-vertical-navigation-itemkey={row.Id}label={row.Name}name={row.Id}title={row.nekpim__Description__c}></lightning-vertical-navigation-item></template></template></lightning-vertical-navigation-section></lightning-vertical-navigation>
// JS for component under test
@wire(getKPISetList,{searchString: '$searchString'})getResults(result){this._getKPISetListRresult=result;if(result.data){this.KPISet=result.data;}elseif(result.error){this.errorMsg=result.error;this.KPISet=undefined;this.KPISetMap=undefined;}}
Run Test pressing the "Run Test" option.
OR in CMD using the command below
c:\Users\bunig\Dev\sfdc\KPIManagement\kpimanagement\node_modules\.bin\lwc-jest -- --json --outputFile c:\Users\bunig\Dev\sfdc\KPIManagement\kpimanagement\.sfdx\tools\testresults\lwc\test-result-f5d14634-162e-4d3e-97aa-868e96092071.json --testLocationInResults --runTestsByPath force-app\main\default\lwc\mainKpiSet\__tests__\mainKpiSet.test.js --testNamePattern "renders records when data returned"
Expected Results
The test is passed as it passed if the "Debug Test" option selected or the test run from the Powershell.
Actual Results
Version
@salesforce/sfdx-lwc-jest: 0.7.1
Node: 12.18.0
Possible Solution
Additional context/Screenshots
The text was updated successfully, but these errors were encountered:
@C00per What is the command line equivalent that the VS Code extension is running for debug mode that passes? Does that command pass when run from CMD?
Also, will you try on a newer version of @salesforce/sfdx-lwc-jest and see if you get the same results?
Description
I'm testing using registerApexTestWireAdapter @wire adapter.
It runs fine if the test is launched from the Powershell. Also, it runs as expected if I launch it using the "Debug Test" option from VSC (Salesforce Extension Pack) See https://developer.salesforce.com/tools/vscode/en/lwc/testing
But if I use the "Run Test" option then DOM is not refreshed after emit() commands in Promise.resolve().then block and the test is failed.
All other tests without egisterApexTestWireAdapter @wire adapter are running fine from the VSC (Salesforce Extension Pack).
I also noticed that the error reproduced if I run the test from CMD but not from Powershell. When I run the test in Powershell it opens CMD during the execution but this time it works as expected. (Test marked green and the correct json created in C:\Users\bunig\Dev\sfdc\KPIManagement\kpimanagement.sfdx\tools\testresults\lwc)
Steps to Reproduce
OR in CMD using the command below
Expected Results
The test is passed as it passed if the "Debug Test" option selected or the test run from the Powershell.
Actual Results
Version
Possible Solution
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: