Vue
Applies to: Vue 2 and Vue 3 applications built with Vite or Vue CLI. For Nuxt, follow the server-side rendering note below.
Toolchain
Source maps
Output to scan
--es6Modules
Vite (create-vue)
Off by default; turn on build.sourcemap
dist
Yes
Vue CLI (webpack)
On by default (productionSourceMap)
dist
No
Vue single-file components (.vue) are reported on the .vue file itself, with each method on its line in the <script> or <script setup> block. Code compiled from <template> is marked as generated, not reported as your methods. The .vue source files must be present in the workspace where slnodejs scan runs (a normal CI checkout).
Vue with Vite
// vite.config.js
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [vue()],
build: { sourcemap: true },
});printf '%s' "$SEALIGHTS_AGENT_TOKEN" > sltoken.txt
npm ci
npx vite build
npx slnodejs config --tokenFile sltoken.txt --appName my-vue-app \
--branchName "$BRANCH_NAME" --buildName "$BUILD_NUMBER"
npx slnodejs scan --tokenFile sltoken.txt --buildSessionIdFile buildSessionId \
--scanDir dist --scmType git --es6Modules \
--instrumentForBrowsers --outputPath sl_dist \
--labId qa-env --excludeSourceMapFiles skipCopyVue with Vue CLI
Source maps are on by default. Make sure vue.config.js does not set productionSourceMap: false:
Deploy the contents of sl_dist in place of dist.
Vue-specific notes
Vue itself
vue, @vue/, vue-router, vuex and pinia inside your bundles are not instrumented by default.
Upgrading from an older slnodejs
Newer versions report .vue methods on their real file and line. The first build after the upgrade shows a one-time jump in "new methods" in coverage and Test Impact Analysis history.
Server-side rendering (Nuxt, Vue SSR)
Scan the client bundles with --instrumentForBrowsers and the server bundles without it, each with its own --moduleName, like the Next.js setup. The server needs the .vue source files where the test listener runs to place coverage on the right lines.
--splitPreambleIntoFile with history-mode routing
Pass a full URL in --preambleFileUrl, or set <base href>.
Check it
Before CI:
npx slnodejs dryRun --scanDir dist --es6Modules --verbose --instrumentForBrowsers --tokenFile sltoken.txt(Vue CLI: without--es6Modules).sl-mapping.jsonshould resolve tosrc/**/*.vueandsrc/**/*.tsfiles.After deployment: Check that it works.
Last updated
Was this helpful?

