Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: nut for multiple --tests using gha #979

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions test/nuts/deploy/runningTests.nut.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
import { expect } from 'chai';
import { DeployResultJson } from '../../../src/utils/types.js';

describe('deploy mdapi format without tracking', () => {
let session: TestSession;
before(async () => {
session = await TestSession.create({
devhubAuthStrategy: 'AUTO',
project: {
gitClone: 'https://github.com/trailheadapps/dreamhouse-lwc.git',
},
scratchOrgs: [
{
edition: 'developer',
tracksSource: false,
setDefault: true,
},
],
});
});

it('deploy changes and run 2 specified tests', () => {
const result = execCmd<DeployResultJson>(
'project:deploy:start --test-level RunSpecifiedTests --tests FileUtilitiesTest --tests GeocodingServiceTest --json'
).jsonOutput?.result;
expect(result?.files).to.not.be.empty;
expect(result?.numberTestsCompleted).to.equal(7);
});

it('deploy dir and run 2 specified tests', () => {
const result = execCmd<DeployResultJson>(
'project:deploy:start --source-dir force-app --test-level RunSpecifiedTests --tests FileUtilitiesTest --tests GeocodingServiceTest --json'
).jsonOutput?.result;
expect(result?.files).to.not.be.empty;
expect(result?.numberTestsCompleted).to.equal(7);
});

it('deploy a bit of metadata and run all tests', () => {
// the project hasn't really deployed because tests keep failing coverage, etc. Deploy so all components are in the org
execCmd<DeployResultJson>('project:deploy:start --source-dir force-app', { ensureExitCode: 0 });
const result = execCmd<DeployResultJson>(
'project:deploy:start --metadata CustomApplication --test-level RunAllTestsInOrg --json'
).jsonOutput?.result;
expect(result?.files).to.not.be.empty;
expect(result?.numberTestsCompleted).to.equal(11); // this number could change if dreamhouse changes
});

after(async () => {
await session?.clean();
});
});
Loading