forcedotcom / cli

Salesforce CLI
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
BSD 3-Clause "New" or "Revised" License
493 stars 78 forks source link

sf force lightning lwc test run returns exit code 0 when tests fail #2991

Closed jamessimone closed 2 weeks ago

jamessimone commented 2 months ago

Summary

Using latest CLI version (@salesforce/cli/2.55.6 win32-x64 node-v20.16.0), these two commands differ when encountering failing LWC jest tests:

This improperly suppresses failures when relying on exit codes (such as in pipeline runs)

Steps To Reproduce

describe('sample failure', () => {
  it('fails', () => {
    expect(1).toBe(2);
  })
})

Expected result

CLI should return exit code 1 when using sf force lightning lwc test run with any test failure

Actual result

CLI returns exit code 0

github-actions[bot] commented 2 months ago

Hello @jamessimone :wave: It looks like you didn't include the full Salesforce CLI version information in your issue. Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

A few more things to check:

Thank you!

github-actions[bot] commented 2 months ago

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

github-actions[bot] commented 2 months ago

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

jamessimone commented 2 months ago

This issue should not be closed

cristiand391 commented 1 month ago

hey, sorry for the late reply.

the command should return the same exit code that sfdx-lwc-test does: https://github.com/salesforcecli/plugin-lwc-test/blob/024530c2ac27f3097f4edb075ccb1cc3b14cabf4/src/commands/force/lightning/lwc/test/run.ts#L60

but looking at the e2e test it seems that hasn't been the case: https://github.com/salesforcecli/plugin-lwc-test/blob/024530c2ac27f3097f4edb075ccb1cc3b14cabf4/test/commands/lwc/test/run.nut.ts#L84

we'll discuss with the owners of sfdx-lwc-test about the current state of the lwc commands and get back.

github-actions[bot] commented 1 month ago

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

jamessimone commented 1 month ago

Bump

github-actions[bot] commented 1 month ago

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

jamessimone commented 1 month ago

Bump

github-actions[bot] commented 1 month ago

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

jamessimone commented 1 month ago

Bump

VivekMChawla commented 1 month ago

@jamessimone - Thanks for keeping this bumped.

My team connected with the team that owns sfdx-lwc-jest

We confirmed that the behavior of sf force lightning lwc test run is incorrect. The command should exit with a status code of 1 if any tests fail.

The CLI team will explore a fix for this issue, but I can't provide a timeline.

git2gus[bot] commented 1 month ago

This issue has been linked to a new work item: W-16884223

jamessimone commented 1 month ago

@VivekMChawla thanks for keeping us updated, it's much appreciated

jshackell-sfdc commented 2 weeks ago

This issue has been fixed in CLI version 2.62.6 (October 16, 2024).

jamessimone commented 2 weeks ago

@jshackell-sfdc thanks!