Using Node.js Agents - Scanning a build

To collect coverage information, SeaLights agents must scan the javascript files for the build information.

Scanning a build

Scanning a build in Node.js is done using the Node.js Build scanner with the build flag.

npx slnodejs scan --tokenfile ./sltoken.txt --buildsessionidfile buildSessionId --workspacepath "." --scm git --es6Modules

For React applications, you should add the flag: --babylonPlugin jsx. To scan both .ts and .tsx files, you should add the flag: --babylonPlugins typescript,jsx

See 'Node.js Command Reference - Scanning a build' for full parameter details

Scanning multi modules

If you want to report separate parts of the application as separate modules, you can do so by scanning each part with the --uniqueModuleId option.

When you finish reporting all the modules, you need to send the event with the buildend command and either the --ok or --failed depending on the result of your build process.

npx slnodejs scan --tokenfile ./path/to/sltoken.txt --buildsessionidfile buildSessionId --workspacepath "." --scm git --es6Modules --uniqueModuleId module-name-one npx slnodejs scan --tokenfile ./path/to/sltoken.txt --buildsessionidfile buildSessionId --workspacepath "." --scm git --es6Modules --uniqueModuleId module-name-two npx slnodejs buildend --tokenfile ./path/to/sltoken.txt --buildsessionidfile buildSessionId --ok