nuxt.renderAndGetWindow(url, options)

  • Type: Function
  • Argument: String

    1. String: URL to render
    2. Optional, Object: options
    • virtualConsole: Boolean (default: true)
  • Returns: Promise
    • Returns: window

Get the window from a given url of a Nuxt.js application.

This method is made for test purposes.

To use this function, you have to install jsdom:

  1. npm install --save-dev jsdom

Example:

  1. const { Nuxt, Builder } = require('nuxt')
  2. const config = require('./nuxt.config.js')
  3. config.dev = false
  4. const nuxt = new Nuxt(config)
  5. nuxt.renderAndGetWindow('http://localhost:3000').then(window => {
  6. // Display the head `<title>`
  7. console.log(window.document.title)
  8. })