Skip to content

Commit 0226549

Browse files
committed
docs: add integration testing documentation to README
1 parent de5f3cf commit 0226549

File tree

1 file changed

+84
-2
lines changed

1 file changed

+84
-2
lines changed

README.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# plugin-lightning-dev
22

3-
<!-- CI Test Comment: Testing CI functionality from main branch -->
4-
53
[![NPM](https://img.shields.io/npm/v/@salesforce/plugin-lightning-dev.svg?label=@salesforce/plugin-lightning-dev)](https://www.npmjs.com/package/@salesforce/plugin-lightning-dev) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-lightning-dev.svg)](https://npmjs.org/package/@salesforce/plugin-lightning-dev) [![License](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/license/apache-2-0)
64

75
This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).
@@ -308,4 +306,88 @@ EXAMPLES
308306

309307
_See code: [src/commands/lightning/dev/site.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/4.3.0/src/commands/lightning/dev/site.ts)_
310308

309+
## Integration Testing
310+
311+
This plugin includes integration (NUT) tests for verifying the Lightning Dev Server functionality using SFDX projects and components. Test data like SFDX projects are created at runtime by the testkit.
312+
313+
### Prerequisites
314+
315+
**Connected App Setup**
316+
Follow the [Connected App Setup Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_connected_app.htm) to:
317+
318+
- Create a connected app
319+
- Enable JWT OAuth
320+
- Configure callback URL and OAuth scopes
321+
322+
**JWT Credentials**
323+
Follow the [Private Key and Certificate Setup Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_key_and_cert.htm) to:
324+
325+
- Generate a private key and certificate
326+
- Upload certificate to the connected app
327+
328+
Set the environment variables (copy from `.env.template` to `.env`):
329+
330+
- `TESTKIT_JWT_CLIENT_ID` - Your connected app client ID
331+
- `TESTKIT_JWT_KEY` - Your private key contents
332+
- `TESTKIT_HUB_INSTANCE` - Salesforce instance URL
333+
- `TESTKIT_ORG_USERNAME` - Your org username for testing
334+
- `OPEN_BROWSER` - Control browser opening (true/false)
335+
336+
### Running Tests
337+
338+
Run all or specific integration tests (NUTs) via:
339+
340+
```bash
341+
# Run all integration tests
342+
yarn test:nuts
343+
344+
# Run component local preview test (local development only)
345+
yarn test:nut:local
346+
347+
# Run by category
348+
yarn test:nuts "test/commands/lightning/dev/component*.nut.ts"
349+
350+
# Run with environment variables
351+
OPEN_BROWSER=false NODE_ENV=production yarn test:nuts
352+
```
353+
354+
### Local-Only Tests
355+
356+
Some NUT tests are designed to run only in local development environments and are automatically skipped in CI pipelines. These tests typically:
357+
358+
- Require specific local setup or resources
359+
- Are too slow for CI environments
360+
- Need manual verification or debugging
361+
- Test features that aren't suitable for automated testing
362+
363+
**Component Local Preview Test**
364+
The `componentLocalPreview.nut.ts` test verifies that the Lightning Dev Server starts correctly and responds to component URLs. This test:
365+
366+
- Runs only locally (skipped when `CI=true`)
367+
- Tests server startup and HTTP response
368+
- Verifies component URL routing (`/c-hello-world/`)
369+
- Can be run with: `yarn test:nut:local`
370+
371+
### Test Data Structure
372+
373+
The testkit creates SFDX projects and test data at runtime:
374+
375+
```
376+
test/
377+
├── testdata/
378+
│ ├── lwc/
379+
│ │ └── helloWorld/
380+
│ └── project-definition.json
381+
```
382+
383+
### Automation with TestKit
384+
385+
Tests use [@salesforce/cli-plugins-testkit](https://github.com/salesforcecli/cli-plugins-testkit) for:
386+
387+
- Temporary project creation at runtime
388+
- JWT-based org login
389+
- Cleanup after each run
390+
391+
No manual authentication is needed. Set the required environment variables once and run tests headlessly.
392+
311393
<!-- commandsstop -->

0 commit comments

Comments
 (0)