This version has been deprecated

Author message:

please use @nuxt/test-utils. https://test-utils.nuxtjs.org/

@nuxtjs/module-test-utils
TypeScript icon, indicating that this package has built-in type declarations

2.0.0-0 • Public • Published

@nuxtjs/module-test-utils

npm version npm downloads Circle CI Codecov License

Test utilities for modules Nuxt.js

📖 Release Notes

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

MIT License

Copyright (c) - Nuxt Community

Readme

Keywords

none

Package Sidebar

Install

npm i @nuxtjs/module-test-utils@2.0.0-0

Version

2.0.0-0

License

MIT

Unpacked Size

8.96 kB

Total Files

4

Last publish

Collaborators

  • pi0
  • ricardogobbosouza