Gathering detailed insights and metrics for nuxt-test-utils
Gathering detailed insights and metrics for nuxt-test-utils
Gathering detailed insights and metrics for nuxt-test-utils
Gathering detailed insights and metrics for nuxt-test-utils
@nuxt/test-utils
Test utilities for Nuxt
@nuxt/test-utils-edge
[](https://nuxt.com)
@nuxt/test-utils-nightly
Test utilities for Nuxt
nuxt-i18n-micro-test-utils
This is a utility library designed to facilitate testing for Nuxt.js applications that use the `nuxt-i18n-micro-core` package. It provides helper functions to handle translations, formatting, and locale switching, simplifying the process of testing intern
Nuxt testing utils (a single home for all your favorite testing utils)
npm install nuxt-test-utils
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
4 Stars
17 Commits
1 Forks
1 Watchers
3 Branches
2 Contributors
Updated on Apr 15, 2021
Latest Version
0.0.1
Package Id
nuxt-test-utils@0.0.1
Unpacked Size
11.05 kB
Size
4.55 kB
File Count
8
NPM Version
6.14.4
Node Version
12.16.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Nuxt testing utils (a single home for all your favorite testing utils).
Some of these utils may help your tests shave off many minutes of run time!
npm i -D nuxt-test-utils
getModuleOptions
ModuleContext
compilePlugin
PluginContext
delay
nextTickP
watchP
This package will come with:
serialize
.Suppose your nuxt.config is set up like this:
1module.exports = { 2 modules: ['./lib/module.js'], 3 myModOpts: { } // NOTE: example purposes only! Use a name best suited for *your* module! 4}
1import TestUtils from 'nuxt-test-utils' 2// or, just pick the utils you need 3import { getModuleOptions, ModuleContext, PluginContext } from 'nuxt-test-utils' 4import config from '@/nuxt.config' // optional, but useful for utilities. 5import path from 'path' 6import Module from '@/lib/module' 7 8const ctx = new ModuleContext({ 9 options: getModuleOptions(config, 'myModOpts'), 10 module: Module, 11 compileOpts: { 12 src: path.resolve('./lib/plugin.js'), 13 tmpFile: path.resolve('./lib/plugin.compiled.js'), 14 overwrite: true 15 } 16}) 17 18// Finally, load the module 19ctx.registerModule() 20 21// Check if the plugin got added: 22t.truthy(ctx.pluginAdded) // ava 23expect(ctx.pluginAdded).toBeTruthy() // jest
getModuleOptions(config, moduleName, optsContainer)
:ModuleContext({ options, module, compileOpts })
:this.addTemplate
were used by the module, this simply mocks the function. It sets this.templateAdded
with the template options provided.addPlugin
: If this.addPlugin
were used by the module, this actually compiles the plugin using the compileOpts provided to ModuleContext
. It also sets this.pluginAdded
with the plugin options provided.compilePlugin
: it also wires up compilePlugin to the ModuleContext, in case you need to use it yourselfregisterModule
: It registers the module with the provided options
to ModuleContext
.compilePlugin({ src, tmpFile, options, overwrite })
src
: String - plugin source filenametmpFile
: String - filename to save the compiled plugin tooptions
: Object - plugin options; i.e., where <%= JSON.stringify(options) %> exists, that will be replaced by the options specified here.overwrite
: Boolean - overwrite the compiled plugin if it already exists. Default: false
.PluginContext(Plugin)
Plugin
- Object - plugin function, usually the export default from your plugin.js file. It usually wraps around an injector.new
operatorinject
, a mock inject
will be called and set this.injected[label]
to the object that the plugin is injecting.delay(ms)
- promisified delay...nothing fancy, just a wrapper around setTimeout
that you can await
on.nextTickP(ctx)
- promisified wrapper around ctx.$nextTick
. Lets you do await nextTickP(ctx)
for cleaner code.watchP(ctx, prop, changesFn)
- promisified wrapper around ctx.$watch
so you can await watchP(ctx, 'someData', () => { ctx.someData = 123 })
. It will resolve once the data has changed.Getting your test environment set up correctly for Nuxt is more than half the battle. Even though test environment is technically beyond the scope of this repo, to avoid having issues being opened on this topic, here are some bullets that may help:
When you first create a Nuxt app using create-nuxt-app, you are asked for choice of test framework. Try running that sample code first before proceeding. If you skipped the test framework selection, you can have a look at their templates and start with those, most likely for ava or jest.
Alternatively, you may find it just as useful to clone Vinayak's repo: https://github.com/vinayakkulkarni/nuxt-ava-e2e-unit-testing
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/15 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
16 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More