Skip to content

Commit

Permalink
fix: set exit code based on executed command (#193)
Browse files Browse the repository at this point in the history
* fix: set exit code based on executed command

* test: fix NUT assertion
  • Loading branch information
WillieRuemmele authored Oct 4, 2024
1 parent 024530c commit 6dd503c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules
oclif.manifest.json
oclif.lock
npm-shrinkwrap.json
.idea/
1 change: 1 addition & 0 deletions src/commands/force/lightning/lwc/test/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class Run extends SfdxCommand {
const scriptRet = this.runJest(args);

this.ux.log(messages.getMessage('logSuccess', [scriptRet.status.toString()]));
process.exitCode=scriptRet.status;
return {
message: messages.getMessage('logSuccess', [scriptRet.status.toString()]),
jestExitCode: scriptRet.status,
Expand Down
2 changes: 1 addition & 1 deletion test/commands/lwc/test/run.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('lightning:lwc:test:run', () => {
await fs.promises.writeFile(testPath, content);

const output = execCmd<RunResult>('force:lightning:lwc:test:run', {
ensureExitCode: 0,
ensureExitCode: 1,
}).shellOutput.stderr;
expect(output).to.include('Test Suites: 1 failed');
expect(output).to.include('Tests: 1 failed');
Expand Down
6 changes: 3 additions & 3 deletions test/commands/lwc/test/setup.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ describe('lightning:lwc:test:setup', () => {
content = await fs.promises.readFile(pjsonPath, 'utf-8');
const forceignoreContent = fs.readFileSync(forceignorePath, 'utf-8');
expect(forceignoreContent).to.include('**/__tests__/**');
expect(content).to.include('"test:unit": "sfdx-lwc-jest --skipApiVersionCheck"');
expect(content).to.include('"test:unit:coverage": "sfdx-lwc-jest --coverage --skipApiVersionCheck"');
expect(content).to.include('"test:unit:debug": "sfdx-lwc-jest --debug --skipApiVersionCheck"');
expect(content).to.include('"test:unit": "sfdx-lwc-jest"');
expect(content).to.include('"test:unit:coverage": "sfdx-lwc-jest --coverage "');
expect(content).to.include('"test:unit:debug": "sfdx-lwc-jest --debug "');
expect(content).to.include('"@salesforce/sfdx-lwc-jest": "^');
});
});

0 comments on commit 6dd503c

Please sign in to comment.