UNPKG

nuxt-dev-ready

Version:

Waits until the Nuxt dev server is loaded. Mainly useful for testing.

18 lines 476 B
import axios from "axios"; import pWaitFor from "p-wait-for"; import portReady from "port-ready"; export default async (port = 3e3) => { await portReady(port); await pWaitFor(async () => { try { const { data } = await axios.get(`http://localhost:${port}`); return !data.includes('id="nuxt_loading_screen"'); } catch (error) { return error.response !== void 0 && error.response.status !== 503; } }, { interval: 100 }); };