Skip to content

Commit fe99d64

Browse files
chore: try shared test setup with one org
1 parent e0536bb commit fe99d64

6 files changed

Lines changed: 22 additions & 9 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"prepack": "sf-prepack",
113113
"prepare": "sf-install",
114114
"test": "wireit",
115-
"test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --reporter-options maxDiffSize=15000",
115+
"test:nuts": "nyc mocha \"test/nuts/main.nut.ts\" \"test/commands/**/*.nut.ts\" --slow 4500 --timeout 600000 --reporter-options maxDiffSize=15000",
116116
"test:only": "wireit",
117117
"version": "oclif readme"
118118
},

test/nuts/agent.generate.authoring-bundle.nut.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { expect } from 'chai';
2020
import { genUniqueString } from '@salesforce/cli-plugins-testkit';
2121
import { execCmd } from '@salesforce/cli-plugins-testkit';
2222
import type { AgentGenerateAuthoringBundleResult } from '../../src/commands/agent/generate/authoring-bundle.js';
23-
import { session, username } from './shared-setup.js';
23+
import { session, username } from './main.nut.js';
2424

2525
describe('agent generate authoring-bundle NUTs', () => {
2626
describe('agent generate authoring-bundle', () => {

test/nuts/agent.nut.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import type { AgentTestResultsResult } from '../../src/commands/agent/test/resul
2828
import type { AgentTestRunResult } from '../../src/flags.js';
2929
import type { AgentCreateSpecResult } from '../../src/commands/agent/generate/agent-spec.js';
3030
import type { AgentCreateResult } from '../../src/commands/agent/create.js';
31-
import { session, username, connection, defaultOrg } from './shared-setup.js';
31+
import { session, username, connection, defaultOrg } from './main.nut.js';
3232

3333
/* eslint-disable no-console */
3434

test/nuts/agent.publish.nut.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { existsSync, renameSync } from 'node:fs';
1818
import { expect } from 'chai';
1919
import { execCmd } from '@salesforce/cli-plugins-testkit';
2020
import type { AgentPublishAuthoringBundleResult } from '../../src/commands/agent/publish/authoring-bundle.js';
21-
import { session, username } from './shared-setup.js';
21+
import { session, username } from './main.nut.js';
2222

2323
describe('agent publish authoring-bundle NUTs', () => {
2424
before(() => {

test/nuts/agent.validate.nut.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { existsSync, renameSync } from 'node:fs';
1818
import { expect } from 'chai';
1919
import { execCmd } from '@salesforce/cli-plugins-testkit';
2020
import type { AgentValidateAuthoringBundleResult } from '../../src/commands/agent/validate/authoring-bundle.js';
21-
import { session, username } from './shared-setup.js';
21+
import { session, username } from './main.nut.js';
2222

2323
describe('agent validate authoring-bundle NUTs', () => {
2424
before(() => {
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ import { sleep } from '@salesforce/kit';
2121

2222
/* eslint-disable no-console */
2323

24+
/**
25+
* Shared test session and connection variables.
26+
* These are set up once in the before hook and exported for use by all test modules.
27+
*/
2428
export let session: TestSession;
2529
export let username: string;
2630
export let defaultOrg: Org;
2731
export let connection: ReturnType<Org['getConnection']>;
2832

2933
/**
30-
* Shared setup for all NUT tests.
31-
* Creates a single scratch org that all tests will use.
34+
* Main test setup - creates a single scratch org that all tests will use.
35+
* This runs once before all test suites.
3236
*/
3337
before(async function () {
3438
this.timeout(600_000); // 10 minutes for setup
@@ -74,12 +78,21 @@ before(async function () {
7478
});
7579

7680
/**
77-
* Shared cleanup for all NUT tests.
78-
* Cleans up the shared scratch org after all tests complete.
81+
* Main test cleanup - cleans up the shared scratch org after all tests complete.
7982
*/
8083
after(async function () {
8184
this.timeout(60_000); // 1 minute for cleanup
8285
if (session) {
8386
await session.clean();
8487
}
8588
});
89+
90+
/**
91+
* Import all test modules that use the shared setup.
92+
* These modules will have access to the session, username, connection, and defaultOrg
93+
* variables exported above.
94+
*/
95+
import './agent.nut.js';
96+
import './agent.generate.authoring-bundle.nut.js';
97+
import './agent.publish.nut.js';
98+
import './agent.validate.nut.js';

0 commit comments

Comments
 (0)