salesforce / sfdx-lwc-jest

Run Jest against LWC components in SFDX workspace environment
MIT License
164 stars 82 forks source link

Tests with registerApexTestWireAdapter fail if test run from Visual Studio Code (Salesforce Extension Pack) #181

Open C00per opened 3 years ago

C00per commented 3 years ago

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

  1. Create a test that uses registerApexTestWireAdapter @wire adapter.

    image

    Version

    • @salesforce/sfdx-lwc-jest: 0.7.1
    • Node: 12.18.0

    Possible Solution

    Additional context/Screenshots

trevor-bliss commented 3 years ago

@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?