Front-End App: Scan & Instrument
The SeaLights Node.js agent can be used to scan and test the Front-end code as well.
Prerequisites
In case your front-end Javascript application is minified and/or uglified as part of its build process, you’ll need to ensure the Source Map files (*.js.map) are available to the Sealights agent inside the application folder - next to the application’s JS files -, pointing to the right source folder and including column information (also known as column-mapping). This will allow the Sealights agent to retrieve the real names of your methods from your source code and not their “obfuscated” version. Please refer to the following page for more information: Javascript & Node.js Source Map Files.
Scanning and Instrumentation
First, the front-end code must be scanned and instrumented to provide the needed information to the SeaLights server.
npx slnodejs scan --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId [--labid <Lab ID>] --instrumentForBrowsers --workspacepath dist --outputpath sl_dist --scm git --es6Modules
After a successful scan
command execution, you should expect:
A line in your console log showing a line similar to
NodeJS-Agent: Scanned X methods and Y branches in Z files.
A new entry in your Sealights' dashboard for the specific application’s version, and the coverage report to show the content of your application (source code)
A new folder in the project directory called
sl_dist
(or the name provided as a value to the--outputpath
parameter)
In case your command execution does not produce the expected results, you can use the dryRun
command to validate your configuration, see dryRun Command: Troubleshooting & Validation.
This will generate a new folder ('sl_dist' in the command above) with the instrumented code: a few Sealights-specific API calls will be added to your JS file to report coverage dynamically as illustrated in the picture below. The content of this Sealights' generated folder needs to be deployed instead of your original code - on the application server - for the client browser to work against during your testing stages, but not in your production environment.

For distributed Test Runner & Test Listener, we recommend using the Lab ID parameter in order to link between the two.
For Front-End instrumented code, this parameter needs to be passed already as part of the the build command.
If the lab ID is not provided, the session ID will be used as a Lab ID
Front-end application as part of an Integration Build
If you are reporting a front-end application as part of an integration build, you'll need to add the -labid <string>
parameter to your command and ensure the value used is the same across all the components.
For more details, please refer to Integration Build
Running tests
Running the tests is done the same as when running Unit or function tests; just here between the start and end steps you run your Front-end tests - See Running Tests
Last updated
Was this helpful?