nuxt.renderAndGetWindow(url, options)
Get the window from a given URL of a Nuxt Application.
-
Type:
Function -
Argument:
String-
String: URL to render -
Optional,
Object: options
-
virtualConsole:
Boolean(default:true)
-
-
Returns:
Promise-
Returns:
window
-
Returns:
This method is made for test purposes.
To use this function, you have to install jsdom:
npm install --save-dev jsdom
Example:
const { loadNuxt } = require('nuxt')
async function init() {
// Assuming you've already built your project
const nuxt = await loadNuxt({ for: 'start' })
await nuxt.listen(3000)
const window = await nuxt.renderAndGetWindow('http://localhost:3000')
// Display the head `<title>`
console.log(window.document.title)
nuxt.close()
}
init()
What's next
Check out the the Components Glossary book
Edit this page on GitHub
Updated at Mon, Feb 28, 2022
Leoš Literák
Trizotti
Clément Ollivier
Sébastien Chopin
Marcello Bachechi
Rodolphe
Thomas Underwood
Shek Evgeniy
felipesuri
Lukasz Formela
Hugo Torzuoli
Sylvain Marroufin
Kareem Dabbeet
tramplay
Daniel Roe
verebelyicsaba
Adam
Nate Butler
Sandra Rodgers
Arpit Patidar
Matthew Kuehn
Steven DUBOIS
Travis Lindsey
syagawa
Maxime
かる
Al Power
Florent Delerue
quanghm
José Manuel Casani Guerra
Unai Mengual
kazuya kawaguchi
Michael Lynch
Tomachi
pooya parsa
Meir Roth
Brett
Adam Miedema
Thomas Bnt
Kazuki Furukawa
Anthony Ruelle
Christophe Carvalho Vilas-Boas
Roman Harmyder