@salesforce/source-testkit 1.2.16 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assertions.d.ts +4 -0
- package/lib/assertions.js +7 -0
- package/lib/testkit.d.ts +4 -9
- package/lib/testkit.js +10 -32
- package/package.json +3 -3
package/lib/assertions.d.ts
CHANGED
|
@@ -117,6 +117,10 @@ export declare class Assertions {
|
|
|
117
117
|
* Expect json to have given error name
|
|
118
118
|
*/
|
|
119
119
|
errorToHaveName(result: JsonMap, name: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* Expect error json to include given message
|
|
122
|
+
*/
|
|
123
|
+
errorToHaveMessage(result: JsonMap, message: string): void;
|
|
120
124
|
/**
|
|
121
125
|
* Expect no apex tests to be run
|
|
122
126
|
*/
|
package/lib/assertions.js
CHANGED
|
@@ -244,6 +244,13 @@ class Assertions {
|
|
|
244
244
|
(0, chai_1.expect)(result).to.have.property('name');
|
|
245
245
|
(0, chai_1.expect)(result.name, `error name to equal ${name}`).to.equal(name);
|
|
246
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Expect error json to include given message
|
|
249
|
+
*/
|
|
250
|
+
errorToHaveMessage(result, message) {
|
|
251
|
+
(0, chai_1.expect)(result).to.have.property('message');
|
|
252
|
+
(0, chai_1.expect)(result.message, `error name to include ${message}`).to.include(message);
|
|
253
|
+
}
|
|
247
254
|
/**
|
|
248
255
|
* Expect no apex tests to be run
|
|
249
256
|
*/
|
package/lib/testkit.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ScratchOrgConfig, CLI } from '@salesforce/cli-plugins-testkit';
|
|
1
2
|
import { AsyncCreatable, Env } from '@salesforce/kit';
|
|
2
3
|
import { AnyJson, Dictionary, JsonMap, Nullable } from '@salesforce/ts-types';
|
|
3
4
|
import { NamedPackageDir } from '@salesforce/core';
|
|
@@ -22,8 +23,6 @@ import { Assertions } from './assertions';
|
|
|
22
23
|
export declare class SourceTestkit extends AsyncCreatable<SourceTestkit.Options> {
|
|
23
24
|
static Env: Env;
|
|
24
25
|
private static DefaultCmdOpts;
|
|
25
|
-
private static LocalDevPath;
|
|
26
|
-
private static LocalProdPath;
|
|
27
26
|
packages: NamedPackageDir[];
|
|
28
27
|
packageNames: string[];
|
|
29
28
|
packagePaths: string[];
|
|
@@ -36,7 +35,6 @@ export declare class SourceTestkit extends AsyncCreatable<SourceTestkit.Options>
|
|
|
36
35
|
private commands;
|
|
37
36
|
private connection;
|
|
38
37
|
private debug;
|
|
39
|
-
private executable;
|
|
40
38
|
private executableName;
|
|
41
39
|
private executionLog;
|
|
42
40
|
private fileTracker;
|
|
@@ -45,7 +43,7 @@ export declare class SourceTestkit extends AsyncCreatable<SourceTestkit.Options>
|
|
|
45
43
|
private orgless;
|
|
46
44
|
private repository;
|
|
47
45
|
private session;
|
|
48
|
-
private
|
|
46
|
+
private scratchOrgs;
|
|
49
47
|
constructor(options: SourceTestkit.Options);
|
|
50
48
|
/**
|
|
51
49
|
* Cleans the test session
|
|
@@ -198,10 +196,6 @@ export declare class SourceTestkit extends AsyncCreatable<SourceTestkit.Options>
|
|
|
198
196
|
* property in the local maxRevision.json to null
|
|
199
197
|
*/
|
|
200
198
|
spoofRemoteChange(globs: string[]): Promise<void>;
|
|
201
|
-
/**
|
|
202
|
-
* Returns true if the executable being used belongs to a local package
|
|
203
|
-
*/
|
|
204
|
-
isLocalExecutable(): boolean;
|
|
205
199
|
/**
|
|
206
200
|
* Move the manifest file to the current working directory.
|
|
207
201
|
*
|
|
@@ -232,12 +226,13 @@ export declare namespace SourceTestkit {
|
|
|
232
226
|
readonly repository: string;
|
|
233
227
|
readonly nut: string;
|
|
234
228
|
readonly orgless?: boolean;
|
|
235
|
-
readonly
|
|
229
|
+
readonly scratchOrgs?: ScratchOrgConfig[];
|
|
236
230
|
};
|
|
237
231
|
type CommandOpts = {
|
|
238
232
|
exitCode: number;
|
|
239
233
|
args: string;
|
|
240
234
|
json: boolean;
|
|
235
|
+
cli: CLI;
|
|
241
236
|
};
|
|
242
237
|
}
|
|
243
238
|
export declare enum Executable {
|
package/lib/testkit.js
CHANGED
|
@@ -41,10 +41,9 @@ const fileTracker_1 = require("./fileTracker");
|
|
|
41
41
|
class SourceTestkit extends kit_1.AsyncCreatable {
|
|
42
42
|
constructor(options) {
|
|
43
43
|
super(options);
|
|
44
|
-
this.executable = options.executable ?? (0, shelljs_1.which)('sfdx')?.stdout ?? 'sfdx';
|
|
45
44
|
this.repository = options.repository;
|
|
46
45
|
this.orgless = !!options.orgless;
|
|
47
|
-
this.
|
|
46
|
+
this.scratchOrgs = options.scratchOrgs || [];
|
|
48
47
|
this.nut = path.basename(options.nut);
|
|
49
48
|
this.debug = (0, debug_1.debug)(`sourceTestkit:${this.nut}`);
|
|
50
49
|
}
|
|
@@ -311,12 +310,6 @@ class SourceTestkit extends kit_1.AsyncCreatable {
|
|
|
311
310
|
}
|
|
312
311
|
await this.writeMaxRevision(maxRevision);
|
|
313
312
|
}
|
|
314
|
-
/**
|
|
315
|
-
* Returns true if the executable being used belongs to a local package
|
|
316
|
-
*/
|
|
317
|
-
isLocalExecutable() {
|
|
318
|
-
return (this.executable.endsWith(SourceTestkit.LocalDevPath) || this.executable.endsWith(SourceTestkit.LocalProdPath));
|
|
319
|
-
}
|
|
320
313
|
/**
|
|
321
314
|
* Move the manifest file to the current working directory.
|
|
322
315
|
*
|
|
@@ -342,9 +335,7 @@ class SourceTestkit extends kit_1.AsyncCreatable {
|
|
|
342
335
|
this.debug(`${command} (expecting exit code: ${exitCode})`);
|
|
343
336
|
await this.fileTracker.updateAll(`PRE: ${command}`);
|
|
344
337
|
await this.executionLog.add(command);
|
|
345
|
-
const result =
|
|
346
|
-
? (0, cli_plugins_testkit_1.execCmd)(command, { ensureExitCode: exitCode, cli: 'sf' })
|
|
347
|
-
: (0, cli_plugins_testkit_1.execCmd)(command, { ensureExitCode: exitCode, cli: 'sfdx' });
|
|
338
|
+
const result = (0, cli_plugins_testkit_1.execCmd)(command, { ensureExitCode: exitCode, cli: options.cli ?? 'inherit' });
|
|
348
339
|
await this.fileTracker.updateAll(`POST: ${command}`);
|
|
349
340
|
if (json) {
|
|
350
341
|
const jsonOutput = result.jsonOutput;
|
|
@@ -373,7 +364,6 @@ class SourceTestkit extends kit_1.AsyncCreatable {
|
|
|
373
364
|
(0, ts_types_1.ensureString)(SourceTestkit.Env.getString('TESTKIT_JWT_CLIENT_ID'));
|
|
374
365
|
(0, ts_types_1.ensureString)(SourceTestkit.Env.getString('TESTKIT_HUB_INSTANCE'));
|
|
375
366
|
}
|
|
376
|
-
SourceTestkit.Env.setString('TESTKIT_EXECUTABLE_PATH', this.executable);
|
|
377
367
|
try {
|
|
378
368
|
this.executableName = await this.getExecutableName();
|
|
379
369
|
this.commands = exports.COMMANDS[this.executableName];
|
|
@@ -407,17 +397,9 @@ class SourceTestkit extends kit_1.AsyncCreatable {
|
|
|
407
397
|
}
|
|
408
398
|
}
|
|
409
399
|
async getExecutableName() {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
.replace(SourceTestkit.LocalDevPath, '');
|
|
414
|
-
const pkgJsonPath = path.join(npmPackagePath, 'package.json');
|
|
415
|
-
const pkgJson = (0, kit_1.parseJsonMap)(await fs.promises.readFile(pkgJsonPath, 'utf8'));
|
|
416
|
-
return pkgJson.oclif.bin;
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
return path.basename(this.executable);
|
|
420
|
-
}
|
|
400
|
+
const pkgJsonPath = path.join(process.cwd(), 'package.json');
|
|
401
|
+
const pkgJson = (0, kit_1.parseJsonMap)(await fs.promises.readFile(pkgJsonPath, 'utf8'));
|
|
402
|
+
return pkgJson.oclif.bin;
|
|
421
403
|
}
|
|
422
404
|
getCommandString(cmdKey) {
|
|
423
405
|
const cmd = this.commands[cmdKey];
|
|
@@ -425,7 +407,7 @@ class SourceTestkit extends kit_1.AsyncCreatable {
|
|
|
425
407
|
return cmd;
|
|
426
408
|
}
|
|
427
409
|
else {
|
|
428
|
-
throw new Error(`${cmdKey} command not implemented for
|
|
410
|
+
throw new Error(`${cmdKey} command not implemented for this executable`);
|
|
429
411
|
}
|
|
430
412
|
}
|
|
431
413
|
/**
|
|
@@ -445,15 +427,12 @@ class SourceTestkit extends kit_1.AsyncCreatable {
|
|
|
445
427
|
throw err;
|
|
446
428
|
}
|
|
447
429
|
async createSession() {
|
|
448
|
-
const
|
|
430
|
+
const scratchOrgs = this.orgless
|
|
449
431
|
? []
|
|
450
|
-
: [
|
|
451
|
-
'sfdx config:set restDeploy=false --global',
|
|
452
|
-
'sfdx force:org:create -d 1 -s -f config/project-scratch-def.json',
|
|
453
|
-
];
|
|
432
|
+
: [{ executable: 'sf', duration: 1, setDefault: true, config: path.join('config', 'project-scratch-def.json') }];
|
|
454
433
|
return await cli_plugins_testkit_1.TestSession.create({
|
|
455
434
|
project: { gitClone: this.repository },
|
|
456
|
-
|
|
435
|
+
scratchOrgs: [...scratchOrgs, ...this.scratchOrgs],
|
|
457
436
|
retries: 2,
|
|
458
437
|
});
|
|
459
438
|
}
|
|
@@ -495,9 +474,8 @@ SourceTestkit.DefaultCmdOpts = {
|
|
|
495
474
|
exitCode: 0,
|
|
496
475
|
args: '',
|
|
497
476
|
json: true,
|
|
477
|
+
cli: 'inherit',
|
|
498
478
|
};
|
|
499
|
-
SourceTestkit.LocalDevPath = path.join('bin', 'dev');
|
|
500
|
-
SourceTestkit.LocalProdPath = path.join('bin', 'run');
|
|
501
479
|
var Executable;
|
|
502
480
|
(function (Executable) {
|
|
503
481
|
Executable["SFDX"] = "sfdx";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/source-testkit",
|
|
3
3
|
"description": "testkit for running NUTs for source related commands",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"!lib/**/*.map"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@salesforce/cli-plugins-testkit": "^
|
|
33
|
+
"@salesforce/cli-plugins-testkit": "^3.0.0",
|
|
34
34
|
"@salesforce/core": "^3.30.2",
|
|
35
35
|
"@salesforce/kit": "^1.5.42",
|
|
36
36
|
"@salesforce/source-deploy-retrieve": "^6.8.2",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"pretty-quick": "^3.1.0",
|
|
72
72
|
"sinon": "^10.0.0",
|
|
73
73
|
"ts-node": "^10.0.0",
|
|
74
|
-
"typescript": "^4.8.
|
|
74
|
+
"typescript": "^4.8.4"
|
|
75
75
|
},
|
|
76
76
|
"config": {
|
|
77
77
|
"commitizen": {
|