API: nuxt.renderAndGetWindow(url, options)

  • Type: Function
  • Argument: String
    • String: URL to render
    • 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')
  6. .then((window) => {
  7. // Display the head `<title>`
  8. console.log(window.document.title)
  9. })