1.6.3 • Published 4 years ago
@nuxtjs/module-test-utils v1.6.3
@nuxtjs/module-test-utils
Test utilities for modules Nuxt.js
Setup
Add @nuxtjs/module-test-utils
dependency to your project
yarn add --dev @nuxtjs/module-test-utils # or npm install --save-dev @nuxtjs/module-test-utils
Usage
You can test the settings by following the example below:
const { setupTest } = require('@nuxtjs/module-test-utils')
describe('module', () => {
const ctx = setupTest({
__dirname,
fixture: 'example',
config: {
myModule: {
test: 123
}
}
})
test('should inject plugin', () => {
expect(ctx).toNuxtPluginAdded({
src: expect.stringContaining('templates/plugin.js'),
fileName: 'myPlugin.js',
options: ctx.config.myModule
})
})
})
Test in browser
import { setupTest, createPage } from '@nuxtjs/module-test-utils'
describe('browser', () => {
const ctx = setupTest({
__dirname,
browser: true,
fixture: 'example'
})
test('should render page', async () => {
const page = await createPage('/')
const html = await page.getHtml()
expect(html).toContain('Works!')
})
})
License
Copyright (c) - Nuxt Community