• 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.

    renderAndGetWindow - 图1

    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 { loadNuxt } = require('nuxt')
    2. async function init() {
    3. // Assuming you've already built your project
    4. const nuxt = await loadNuxt({ for: 'start' })
    5. await nuxt.listen(3000)
    6. const window = await nuxt.renderAndGetWindow('http://localhost:3000')
    7. // Display the head `<title>`
    8. console.log(window.document.title)
    9. nuxt.close()
    10. }
    11. init()