From 235d114e1230e8ef412f2dd7e70db5ec187f5010 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Sun, 24 Mar 2019 17:09:48 +0430 Subject: [PATCH] improve test --- test/_utils.js | 3 +-- test/module.test.js | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/test/_utils.js b/test/_utils.js index cf49b57..3b586b6 100644 --- a/test/_utils.js +++ b/test/_utils.js @@ -17,10 +17,9 @@ async function setupNuxt(config) { await builder.validatePages() await builder.generateRoutesAndFiles() - nuxt.builder = builder - await nuxt.listen(3000) + await nuxt.ready() return nuxt } diff --git a/test/module.test.js b/test/module.test.js index bcf007e..d2ff097 100644 --- a/test/module.test.js +++ b/test/module.test.js @@ -1,4 +1,4 @@ -const ky = require('ky-universal') +const fetch = require('node-fetch') const { setupNuxt } = require('./_utils') const url = path => `http://localhost:3000${path}` @@ -8,8 +8,8 @@ describe('module', () => { test('setup', async () => { nuxt = await setupNuxt() - await nuxt.builder.build() + await nuxt.listen(3000) }) afterAll(async () => { @@ -25,7 +25,7 @@ describe('module', () => { }) test('asyncData', async () => { - const html = await ky.get(url('/asyncData')).text() + const html = await fetch(url('/asyncData')).then(r => r.text()) expect(html).toContain('foo/bar') }) @@ -46,8 +46,7 @@ describe('module', () => { }) test('ssr', async () => { - const makeReq = login => ky - .get(url('/ssr' + (login ? '?login' : ''))) + const makeReq = login => fetch(url('/ssr' + (login ? '?login' : ''))) .then(r => r.text()) .then(h => /session-[0-9]+/.exec(h)) .then(m => (m && m[0] ? m[0] : null)) @@ -65,8 +64,7 @@ describe('module', () => { }) test('ssr no brotli', async () => { - const makeReq = login => ky - .get(url('/ssr' + (login ? '?login' : ''))) + const makeReq = login => fetch(url('/ssr' + (login ? '?login' : ''))) .then(r => r.text()) .then(h => /encoding-\$(.*)\$/.exec(h)) .then(m => (m && m[1] ? m[1] : null))