Clone the project and cd
into it:
$ git clone [email protected]:forcedotcom/salesforcedx-apex.git
$ cd salesforcedx-apex
Ensure that you have Yarn installed, then run:
$ yarn install
$ yarn build
- We work in
develop
. - Our released (production) branch is
main
. - Our work happens in topic branches (feature and/or bug fix).
- These branches are based on
develop
and can live in forks for external contributors or within this repository for authors. - Be sure to prefix branches in this repository with
<developer-name>/
. - Be sure to keep branches up-to-date using
rebase
.
- These branches are based on
Install the library locally by adding this information to your project's package.json
:
"@salesforce/apex-node": "file://path/to/salesforcedx-apex/packages/apex-node"
Using the library directly requires access to a Salesforce Connection. Create an instance of the specific Apex service to get access to the required methods. For example, to get a list of logs:
$ const authInfo = await AuthInfo.create({ username: myAdminUsername });
$ const connection = await Connection.create({ authInfo });
$ const logService = new LogService(connection);
$ const logList = await logService.getLogRecords();
Similarly, to run tests using the Test Service:
$ const authInfo = await AuthInfo.create({ username: myAdminUsername });
$ const connection = await Connection.create({ authInfo });
$ const testService = new TestService(connection);
$ const payload = testService.buildAsyncPayload(testLevel, tests, classnames, suitenames);
$ const testResults = await testService.runTestAsynchronous(payload, codeCoverage);
You can use the same pattern for the Execute Service
as well.
$ yarn test
When running tests, code changes don't need to be built with
yarn build
first because the test suite uses ts-node as its runtime environment. Otherwise, runyarn build
before manually testing changes.