test: use got instead of request (#6740)

This commit is contained in:
Xin Du (Clark) 2019-12-02 15:23:56 +00:00 committed by Pooya Parsa
parent 04e4e0f391
commit 5945845c76
18 changed files with 213 additions and 167 deletions

View File

@ -50,6 +50,7 @@
"fs-extra": "^8.1.0",
"get-port": "^5.0.0",
"glob": "^7.1.6",
"got": "^9.6.0",
"is-wsl": "^2.1.1",
"jest": "^24.9.0",
"jest-junit": "^9.0.0",
@ -61,7 +62,6 @@
"node-sass": "^4.13.0",
"puppeteer-core": "^2.0.0",
"request": "^2.88.0",
"request-promise-native": "^1.0.8",
"rimraf": "^3.0.0",
"rollup": "^1.27.5",
"rollup-plugin-alias": "^2.2.0",

View File

@ -141,17 +141,14 @@ describe('basic dev', () => {
// })
test('/__open-in-editor (open-in-editor)', async () => {
const { body } = await rp(
url('/__open-in-editor?file=pages/index.vue'),
{ resolveWithFullResponse: true }
)
const { body } = await rp(url('/__open-in-editor?file=pages/index.vue'))
expect(body).toBe('')
})
test('/__open-in-editor should return error (open-in-editor)', async () => {
await expect(rp(url('/__open-in-editor?file='))).rejects.toMatchObject({
statusCode: 500,
error: 'launch-editor-middleware: required query param "file" is missing.'
body: 'launch-editor-middleware: required query param "file" is missing.'
})
})
@ -165,8 +162,7 @@ describe('basic dev', () => {
const opts = {
headers: {
accept: 'application/json'
},
resolveWithFullResponse: true
}
}
await expect(rp(url('/error'), opts)).rejects.toMatchObject({
statusCode: 500,

View File

@ -137,7 +137,7 @@ describe('basic generate', () => {
})
test('/users/1/index.html', async () => {
const html = await rp(url('/users/1/index.html'))
const { body: html } = await rp(url('/users/1/index.html'))
expect(html).toContain('<h1>User: 1</h1>')
expect(
existsSync(resolve(distDir, 'users/1/index.html'))
@ -146,12 +146,12 @@ describe('basic generate', () => {
})
test('/users/2', async () => {
const html = await rp(url('/users/2'))
const { body: html } = await rp(url('/users/2'))
expect(html).toContain('<h1>User: 2</h1>')
})
test('/users/3 (payload given)', async () => {
const html = await rp(url('/users/3'))
const { body: html } = await rp(url('/users/3'))
expect(html).toContain('<h1>User: 3000</h1>')
})
@ -165,7 +165,7 @@ describe('basic generate', () => {
})
test('/validate should not be server-rendered', async () => {
const html = await rp(url('/validate'))
const { body: html } = await rp(url('/validate'))
expect(html).toContain('<div id="__nuxt"></div>')
expect(html).toContain('serverRendered:!1')
})
@ -183,7 +183,7 @@ describe('basic generate', () => {
})
test('/redirect should not be server-rendered', async () => {
const html = await rp(url('/redirect'))
const { body: html } = await rp(url('/redirect'))
expect(html).toContain('<div id="__nuxt"></div>')
expect(html).toContain('serverRendered:!1')
})
@ -223,7 +223,7 @@ describe('basic generate', () => {
})
test('creates /200.html as fallback', async () => {
const html = await rp(url('/200.html'))
const { body: html } = await rp(url('/200.html'))
expect(html.includes('<h1>Index page</h1>')).toBe(false)
expect(html.includes('data-server-rendered')).toBe(false)
expect(existsSync(resolve(distDir, '200.html'))).toBe(true)

View File

@ -34,9 +34,7 @@ describe('basic ssr csp', () => {
'Not contain Content-Security-Policy header, when csp is false',
async () => {
nuxt = await startCspServer(false)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[cspHeader]).toBe(undefined)
}
@ -46,9 +44,7 @@ describe('basic ssr csp', () => {
'Contain Content-Security-Policy header, when csp is set',
async () => {
nuxt = await startCspServer(true)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[cspHeader]).toMatch(/^script-src 'self' 'sha256-.*'$/)
}
@ -58,9 +54,7 @@ describe('basic ssr csp', () => {
'Contain Content-Security-Policy-Report-Only header, when explicitly asked for',
async () => {
nuxt = await startCspDevServer({ reportOnly: true })
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[reportOnlyHeader]).toMatch(/^script-src 'self' 'sha256-.*'$/)
}
@ -70,9 +64,7 @@ describe('basic ssr csp', () => {
'Contain only unique hashes in header when csp is set',
async () => {
nuxt = await startCspServer(true)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
const hashes = headers[cspHeader].split(' ').filter(s => s.startsWith('\'sha256-'))
const uniqueHashes = [...new Set(hashes)]
@ -89,9 +81,7 @@ describe('basic ssr csp', () => {
}
nuxt = await startCspServer(cspOption)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[cspHeader]).toMatch(/^script-src 'self' 'sha256-.*'/)
expect(headers[cspHeader]).toContain('https://example.com')
@ -111,9 +101,7 @@ describe('basic ssr csp', () => {
}
nuxt = await startCspServer(cspOption)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[cspHeader]).toMatch(/default-src 'none'/)
expect(headers[cspHeader]).toMatch(/script-src 'sha256-(.*)?' 'self'/)
@ -133,9 +121,7 @@ describe('basic ssr csp', () => {
}
nuxt = await startCspServer(cspOption)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[cspHeader]).toMatch(/default-src 'none'/)
expect(headers[cspHeader]).toMatch(/script-src 'sha256-.*' 'self'$/)
@ -156,14 +142,10 @@ describe('basic ssr csp', () => {
})
for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
await rp(url('/stateless'))
}
const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateful'))
const hashes = headers[cspHeader].split(' ').filter(s => s.startsWith('\'sha256-'))
const uniqueHashes = [...new Set(hashes)]
@ -184,14 +166,10 @@ describe('basic ssr csp', () => {
})
for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
await rp(url('/stateless'))
}
const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateful'))
expect(headers[cspHeader]).toMatch(/script-src 'self' 'unsafe-inline'$/)
}
@ -210,14 +188,10 @@ describe('basic ssr csp', () => {
})
for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
await rp(url('/stateless'))
}
const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateful'))
expect(headers[cspHeader]).toMatch(/script-src 'sha256-.*' 'self' 'unsafe-inline'$/)
}
@ -237,14 +211,10 @@ describe('basic ssr csp', () => {
})
for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
await rp(url('/stateless'))
}
const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateful'))
expect(headers[cspHeader]).toMatch(/script-src 'sha256-.*' 'self' 'unsafe-inline'$/)
}
@ -256,9 +226,7 @@ describe('basic ssr csp', () => {
'Not contain Content-Security-Policy-Report-Only header, when csp is false',
async () => {
nuxt = await startCspDevServer(false)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[reportOnlyHeader]).toBe(undefined)
}
@ -268,9 +236,7 @@ describe('basic ssr csp', () => {
'Contain Content-Security-Policy header, when explicitly asked for',
async () => {
nuxt = await startCspDevServer({ reportOnly: false })
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[cspHeader]).toMatch(/^script-src 'self' 'sha256-.*'$/)
}
@ -280,9 +246,7 @@ describe('basic ssr csp', () => {
'Contain Content-Security-Policy header, when csp is set',
async () => {
nuxt = await startCspDevServer(true)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[reportOnlyHeader]).toMatch(/^script-src 'self' 'sha256-.*'$/)
}
@ -292,9 +256,7 @@ describe('basic ssr csp', () => {
'Contain only unique hashes in header when csp is set',
async () => {
nuxt = await startCspDevServer(true)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
const hashes = headers[reportOnlyHeader].split(' ').filter(s => s.startsWith('\'sha256-'))
const uniqueHashes = [...new Set(hashes)]
@ -311,9 +273,7 @@ describe('basic ssr csp', () => {
}
nuxt = await startCspDevServer(cspOption)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[reportOnlyHeader]).toMatch(/^script-src 'self' 'sha256-.*'/)
expect(headers[reportOnlyHeader]).toContain('https://example.com')
@ -333,9 +293,7 @@ describe('basic ssr csp', () => {
}
nuxt = await startCspDevServer(cspOption)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[reportOnlyHeader]).toMatch(/default-src 'none'/)
expect(headers[reportOnlyHeader]).toMatch(/script-src 'sha256-(.*)?' 'self'/)
@ -355,9 +313,7 @@ describe('basic ssr csp', () => {
}
nuxt = await startCspDevServer(cspOption)
const { headers } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateless'))
expect(headers[reportOnlyHeader]).toMatch(/default-src 'none'/)
expect(headers[reportOnlyHeader]).toMatch(/script-src 'sha256-.*' 'self'$/)
@ -378,14 +334,10 @@ describe('basic ssr csp', () => {
})
for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
await rp(url('/stateless'))
}
const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateful'))
const hashes = headers[reportOnlyHeader].split(' ').filter(s => s.startsWith('\'sha256-'))
const uniqueHashes = [...new Set(hashes)]
@ -405,14 +357,10 @@ describe('basic ssr csp', () => {
}
}
nuxt = await startCspDevServer(cspOption)
const { headers: user1Header } = await rp(url('/users/1'), {
resolveWithFullResponse: true
})
const { headers: user1Header } = await rp(url('/users/1'))
const user1Hashes = user1Header[reportOnlyHeader].split(' ').filter(s => s.startsWith('\'sha256-'))
const { headers: user2Header } = await rp(url('/users/2'), {
resolveWithFullResponse: true
})
const { headers: user2Header } = await rp(url('/users/2'))
const user2Hashes = new Set(user2Header[reportOnlyHeader].split(' ').filter(s => s.startsWith('\'sha256-')))
const intersection = new Set(user1Hashes.filter(x => user2Hashes.has(x)))
@ -432,14 +380,10 @@ describe('basic ssr csp', () => {
})
for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
await rp(url('/stateless'))
}
const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateful'))
expect(headers[reportOnlyHeader]).toMatch(/script-src 'self' 'unsafe-inline'$/)
}
@ -458,14 +402,10 @@ describe('basic ssr csp', () => {
})
for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
await rp(url('/stateless'))
}
const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateful'))
expect(headers[cspHeader]).toMatch(/script-src 'sha256-.*' 'self' 'unsafe-inline'$/)
}
@ -485,14 +425,10 @@ describe('basic ssr csp', () => {
})
for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
await rp(url('/stateless'))
}
const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/stateful'))
expect(headers[cspHeader]).toMatch(/script-src 'sha256-.*' 'self' 'unsafe-inline'$/)
}

View File

@ -223,8 +223,7 @@ describe('basic ssr', () => {
const opts = {
headers: {
accept: 'application/json'
},
resolveWithFullResponse: true
}
}
await expect(rp(url('/error'), opts)).rejects.toMatchObject({
statusCode: 500,
@ -247,7 +246,7 @@ describe('basic ssr', () => {
test('/error2 status code', async () => {
await expect(rp(url('/error2'))).rejects.toMatchObject({
statusCode: 500,
message: expect.stringContaining('Custom error')
body: expect.stringContaining('Custom error')
})
})
@ -297,12 +296,11 @@ describe('basic ssr', () => {
})
test('ETag Header', async () => {
const { headers: { etag } } = await rp(url('/stateless'), {
resolveWithFullResponse: true
})
const { headers: { etag } } = await rp(url('/stateless'))
// Verify functionality
await expect(rp(url('/stateless'), { headers: { 'If-None-Match': etag } }))
.rejects.toMatchObject({ statusCode: 304 })
const response = await rp(url('/stateless'), { headers: { 'If-None-Match': etag } })
await expect(response).toMatchObject({ statusCode: 304 })
})
test('/_nuxt/ should return 404', async () => {

View File

@ -74,7 +74,7 @@ describe.posix('cli', () => {
expect(error).toBe(undefined)
const html = await rp(url('/'))
const { body: html } = await rp(url('/'))
expect(html).toMatch(('<div>CLI Test</div>'))
await close(nuxtStart)

View File

@ -44,9 +44,7 @@ describe('custom-dirs', () => {
})
test('custom static directory', async () => {
const { headers } = await rp(url('/test.txt'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/test.txt'))
expect(headers['cache-control']).toBe('public, max-age=0')
})

View File

@ -16,20 +16,14 @@ describe('dist options', () => {
})
test('Specify maxAge/index in render.dist options', async () => {
const { body } = await rp(url('/'), {
resolveWithFullResponse: true
})
const { body } = await rp(url('/'))
try {
await rp(url('/_nuxt/'), {
resolveWithFullResponse: true
})
await rp(url('/_nuxt/'))
} catch (err) {
expect(err.toString().includes('StatusCodeError'))
}
const distFile = body.match(/\/_nuxt\/.+?\.js/)[0]
const { headers } = await rp(url(distFile), {
resolveWithFullResponse: true
})
const { headers } = await rp(url(distFile))
const twoYears = (((60 * 60 * 24 * 365) * 2) / 1000).toString()
expect(headers['cache-control']).toContain(twoYears)
})

View File

@ -28,7 +28,7 @@ describe('express', () => {
})
test('/stateless with express', async () => {
const html = await rp(url('/stateless'))
const { body: html } = await rp(url('/stateless'))
expect(html).toContain('<h1>My component!</h1>')
})

View File

@ -14,25 +14,25 @@ describe('modern client mode (SSR)', () => {
})
test('should contain nomodule legacy resources', async () => {
const response = await rp(url('/'))
const { body: response } = await rp(url('/'))
expect(response).toContain('script nomodule crossorigin="use-credentials" src="/_nuxt/app.js')
expect(response).toContain('script nomodule crossorigin="use-credentials" src="/_nuxt/commons.app.js')
})
test('should contain module modern resources', async () => {
const response = await rp(url('/'))
const { body: response } = await rp(url('/'))
expect(response).toContain('<script type="module" crossorigin="use-credentials" src="/_nuxt/modern-app.js"')
expect(response).toContain('<script type="module" crossorigin="use-credentials" src="/_nuxt/modern-commons.app.js"')
})
test('should contain module preload resources', async () => {
const response = await rp(url('/'))
const { body: response } = await rp(url('/'))
expect(response).toContain('<link rel="modulepreload" crossorigin="use-credentials" href="/_nuxt/modern-app.js" as="script">')
expect(response).toContain('<link rel="modulepreload" crossorigin="use-credentials" href="/_nuxt/modern-commons.app.js" as="script">')
})
test('should contain module http2 pushed resources', async () => {
const { headers: { link } } = await rp(url('/'), { resolveWithFullResponse: true })
const { headers: { link } } = await rp(url('/'))
expect(link).toEqual([
'</_nuxt/modern-runtime.js>; rel=modulepreload; crossorigin=use-credentials; as=script',
'</_nuxt/modern-commons.app.js>; rel=modulepreload; crossorigin=use-credentials; as=script',
@ -42,7 +42,7 @@ describe('modern client mode (SSR)', () => {
})
test('should contain safari fix script', async () => {
const response = await rp(url('/'))
const { body: response } = await rp(url('/'))
expect(response).toContain('"noModule"')
})

View File

@ -22,31 +22,29 @@ describe('modern server mode', () => {
})
test('should use legacy resources by default', async () => {
const response = await rp(url('/'))
const { body: response } = await rp(url('/'))
expect(response).toContain('/_nuxt/app.js')
expect(response).toContain('/_nuxt/commons.app.js')
})
test('should use modern resources for modern resources', async () => {
const response = await rp(url('/'), { headers: { 'user-agent': modernUA } })
const { body: response } = await rp(url('/'), { headers: { 'user-agent': modernUA } })
expect(response).toContain('/_nuxt/modern-app.js')
expect(response).toContain('/_nuxt/modern-commons.app.js')
})
test('should include es6 syntax in modern resources', async () => {
const response = await rp(url(`/_nuxt/modern-${wChunk('pages/index.js')}`))
const { body: response } = await rp(url(`/_nuxt/modern-${wChunk('pages/index.js')}`))
expect(response).toContain('arrow: () => {')
})
test('should not include es6 syntax in normal resources', async () => {
const response = await rp(url(`/_nuxt/${wChunk('pages/index.js')}`))
const { body: response } = await rp(url(`/_nuxt/${wChunk('pages/index.js')}`))
expect(response).toContain('arrow: function arrow() {')
})
test('should contain legacy http2 pushed resources', async () => {
const { headers: { link } } = await rp(url('/'), {
resolveWithFullResponse: true
})
const { headers: { link } } = await rp(url('/'))
expect(link).toEqual([
'</_nuxt/runtime.js>; rel=preload; crossorigin=use-credentials; as=script',
'</_nuxt/commons.app.js>; rel=preload; crossorigin=use-credentials; as=script',
@ -57,8 +55,7 @@ describe('modern server mode', () => {
test('should contain module http2 pushed resources', async () => {
const { headers: { link } } = await rp(url('/'), {
headers: { 'user-agent': modernUA },
resolveWithFullResponse: true
headers: { 'user-agent': modernUA }
})
expect(link).toEqual([
'</_nuxt/modern-runtime.js>; rel=preload; crossorigin=use-credentials; as=script',
@ -70,7 +67,6 @@ describe('modern server mode', () => {
test('Vary header should contain User-Agent', async () => {
const { headers: { vary } } = await rp(url('/'), {
resolveWithFullResponse: true,
headers: { 'user-agent': modernUA }
})
expect(vary).toContain('User-Agent')

View File

@ -22,25 +22,25 @@ describe('modern client mode (SPA)', () => {
})
test('should contain nomodule legacy resources', async () => {
const response = await rp(url('/'))
const { body: response } = await rp(url('/'))
expect(response).toContain('src="/_nuxt/app.js" crossorigin="use-credentials" nomodule')
expect(response).toContain('src="/_nuxt/commons.app.js" crossorigin="use-credentials" nomodule')
})
test('should contain module modern resources', async () => {
const response = await rp(url('/'))
const { body: response } = await rp(url('/'))
expect(response).toContain('<script type="module" src="/_nuxt/modern-app.js" crossorigin="use-credentials"')
expect(response).toContain('<script type="module" src="/_nuxt/modern-commons.app.js" crossorigin="use-credentials"')
})
test('should contain legacy preload resources', async () => {
const response = await rp(url('/'))
const { body: response } = await rp(url('/'))
expect(response).toContain('<link rel="preload" crossorigin="use-credentials" href="/_nuxt/app.js" as="script">')
expect(response).toContain('<link rel="preload" crossorigin="use-credentials" href="/_nuxt/commons.app.js" as="script">')
})
test('should contain legacy http2 pushed resources', async () => {
const { headers: { link } } = await rp(url('/'), { resolveWithFullResponse: true })
const { headers: { link } } = await rp(url('/'))
expect(link).toEqual([
'</_nuxt/runtime.js>; rel=preload; crossorigin=use-credentials; as=script',
'</_nuxt/commons.app.js>; rel=preload; crossorigin=use-credentials; as=script',
@ -49,13 +49,13 @@ describe('modern client mode (SPA)', () => {
})
test('should contain modern preload resources', async () => {
const response = await rp(url('/'), { headers: { 'user-agent': modernUA } })
const { body: response } = await rp(url('/'), { headers: { 'user-agent': modernUA } })
expect(response).toContain('<link rel="modulepreload" crossorigin="use-credentials" href="/_nuxt/modern-app.js" as="script">')
expect(response).toContain('<link rel="modulepreload" crossorigin="use-credentials" href="/_nuxt/modern-commons.app.js" as="script">')
})
test('should contain modern http2 pushed resources', async () => {
const { headers: { link } } = await rp(url('/'), { headers: { 'user-agent': modernUA }, resolveWithFullResponse: true })
const { headers: { link } } = await rp(url('/'), { headers: { 'user-agent': modernUA } })
expect(link).toEqual([
'</_nuxt/modern-runtime.js>; rel=modulepreload; crossorigin=use-credentials; as=script',
'</_nuxt/modern-commons.app.js>; rel=modulepreload; crossorigin=use-credentials; as=script',

View File

@ -53,17 +53,17 @@ describe('module', () => {
// })
test('Middleware', async () => {
const response = await rp(url('/api'))
const { body: response } = await rp(url('/api'))
expect(response).toBe('It works!')
})
test('serverMiddleware with path', async () => {
const response = await rp(url('/midd3'))
const { body: response } = await rp(url('/midd3'))
expect(response).toBe('Be creative when writing test strings! Hey Mama :wave:')
})
test('Hooks - Use external middleware before render', async () => {
const response = await rp(url('/use-middleware'))
const { body: response } = await rp(url('/use-middleware'))
expect(response).toBe('Use external middleware')
})

View File

@ -49,7 +49,7 @@ const stressTest = async (_url, concurrency = 2, steps = 4) => {
await sequence(range(steps), async () => {
await parallel(range(concurrency), async () => {
const response = await rp(url(_url), { resolveWithFullResponse: true })
const response = await rp(url(_url))
// Status Code
const code = response.statusCode
if (!statusCodes[code]) {

View File

@ -16,7 +16,7 @@ describe('unicode-base', () => {
})
test('/ö/ (router base)', async () => {
const response = await rp(url('/ö/'))
const { body: response } = await rp(url('/ö/'))
expect(response).toContain('<h1>Unicode base works!</h1>')
})

View File

@ -171,9 +171,7 @@ describe('with-config', () => {
})
test('Check /test/test.txt with custom serve-static options', async () => {
const { headers } = await rp(url('/test/test.txt'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/test/test.txt'))
expect(headers['cache-control']).toBe('public, max-age=31536000')
})
@ -211,9 +209,7 @@ describe('with-config', () => {
})
test('/ with Server-Timing header', async () => {
const { headers } = await rp(url('/test'), {
resolveWithFullResponse: true
})
const { headers } = await rp(url('/test'))
expect(headers['server-timing']).toMatch(/total;dur=\d+(\.\d+)?;desc="Nuxt Server Time"/)
})

View File

@ -2,7 +2,7 @@ import klawSync from 'klaw-sync'
export { getNuxtConfig } from '../../packages/config'
export { default as getPort } from 'get-port'
export { default as rp } from 'request-promise-native'
export { default as rp } from 'got'
export * from './nuxt'
export * from './resource-size'

136
yarn.lock
View File

@ -1743,6 +1743,18 @@
dependencies:
"@types/node" ">= 8"
"@sindresorhus/is@^0.14.0":
version "0.14.0"
resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==
"@szmarczak/http-timer@^1.1.2":
version "1.1.2"
resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421"
integrity sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==
dependencies:
defer-to-connect "^1.0.1"
"@types/babel__core@^7.1.0":
version "7.1.3"
resolved "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.3.tgz#e441ea7df63cd080dfcd02ab199e6d16a735fc30"
@ -3020,6 +3032,19 @@ cache-loader@^4.1.0:
neo-async "^2.6.1"
schema-utils "^2.0.0"
cacheable-request@^6.0.0:
version "6.1.0"
resolved "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912"
integrity sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==
dependencies:
clone-response "^1.0.2"
get-stream "^5.1.0"
http-cache-semantics "^4.0.0"
keyv "^3.0.0"
lowercase-keys "^2.0.0"
normalize-url "^4.1.0"
responselike "^1.0.2"
call-me-maybe@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b"
@ -3307,6 +3332,13 @@ clone-deep@^4.0.1:
kind-of "^6.0.2"
shallow-clone "^3.0.0"
clone-response@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b"
integrity sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=
dependencies:
mimic-response "^1.0.0"
clone@^1.0.2:
version "1.0.4"
resolved "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
@ -4102,6 +4134,13 @@ decode-uri-component@^0.2.0:
resolved "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=
decompress-response@^3.3.0:
version "3.3.0"
resolved "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3"
integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=
dependencies:
mimic-response "^1.0.0"
dedent@^0.7.0:
version "0.7.0"
resolved "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c"
@ -4129,6 +4168,11 @@ defaults@^1.0.3:
dependencies:
clone "^1.0.2"
defer-to-connect@^1.0.1:
version "1.1.0"
resolved "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.0.tgz#b41bd7efa8508cef13f8456975f7a278c72833fd"
integrity sha512-WE2sZoctWm/v4smfCAdjYbrfS55JiMRdlY9ZubFhsYbteCK9+BvAx4YV7nPjYM6ZnX5BcoVKwfmyx9sIFTgQMQ==
define-properties@^1.1.2, define-properties@^1.1.3:
version "1.1.3"
resolved "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1"
@ -4354,6 +4398,11 @@ dot-prop@^4.1.1, dot-prop@^4.2.0:
dependencies:
is-obj "^1.0.0"
duplexer3@^0.1.4:
version "0.1.4"
resolved "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"
integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=
duplexer@^0.1.1:
version "0.1.1"
resolved "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
@ -5391,7 +5440,7 @@ get-stream@^4.0.0, get-stream@^4.1.0:
dependencies:
pump "^3.0.0"
get-stream@^5.0.0:
get-stream@^5.0.0, get-stream@^5.1.0:
version "5.1.0"
resolved "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz#01203cdc92597f9b909067c3e656cc1f4d3c4dc9"
integrity sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==
@ -5538,6 +5587,23 @@ globule@^1.0.0:
lodash "~4.17.10"
minimatch "~3.0.2"
got@^9.6.0:
version "9.6.0"
resolved "https://registry.npmjs.org/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85"
integrity sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==
dependencies:
"@sindresorhus/is" "^0.14.0"
"@szmarczak/http-timer" "^1.1.2"
cacheable-request "^6.0.0"
decompress-response "^3.3.0"
duplexer3 "^0.1.4"
get-stream "^4.1.0"
lowercase-keys "^1.0.1"
mimic-response "^1.0.1"
p-cancelable "^1.0.0"
to-readable-stream "^1.0.0"
url-parse-lax "^3.0.0"
graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2:
version "4.2.3"
resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423"
@ -5807,6 +5873,11 @@ http-cache-semantics@^3.8.1:
resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2"
integrity sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w==
http-cache-semantics@^4.0.0:
version "4.0.3"
resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.3.tgz#495704773277eeef6e43f9ab2c2c7d259dda25c5"
integrity sha512-TcIMG3qeVLgDr1TEd2XvHaTnMPwYQUQMIBLy+5pLSDKYFc7UIqj39w8EGzZkaxoLv/l2K8HaI0t5AVA+YYgUew==
http-errors@1.7.2:
version "1.7.2"
resolved "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f"
@ -6953,6 +7024,11 @@ jsesc@~0.5.0:
resolved "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"
integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=
json-buffer@3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898"
integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=
json-parse-better-errors@^1.0.0, json-parse-better-errors@^1.0.1, json-parse-better-errors@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
@ -7019,6 +7095,13 @@ jsprim@^1.2.2:
json-schema "0.2.3"
verror "1.10.0"
keyv@^3.0.0:
version "3.1.0"
resolved "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9"
integrity sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==
dependencies:
json-buffer "3.0.0"
kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0:
version "3.2.2"
resolved "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
@ -7345,6 +7428,16 @@ lower-case@^1.1.1:
resolved "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac"
integrity sha1-miyr0bno4K6ZOkv31YdcOcQujqw=
lowercase-keys@^1.0.0, lowercase-keys@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f"
integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==
lowercase-keys@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479"
integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==
lru-cache@^4.0.1, lru-cache@^4.1.2:
version "4.1.5"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
@ -7624,6 +7717,11 @@ mimic-fn@^2.1.0:
resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
mimic-response@^1.0.0, mimic-response@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b"
integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==
minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"
@ -8105,6 +8203,11 @@ normalize-url@^3.0.0, normalize-url@^3.3.0:
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-3.3.0.tgz#b2e1c4dc4f7c6d57743df733a4f5978d18650559"
integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==
normalize-url@^4.1.0:
version "4.5.0"
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129"
integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==
npm-bundled@^1.0.1:
version "1.0.6"
resolved "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd"
@ -8377,6 +8480,11 @@ osenv@0, osenv@^0.1.4, osenv@^0.1.5:
os-homedir "^1.0.0"
os-tmpdir "^1.0.0"
p-cancelable@^1.0.0:
version "1.1.0"
resolved "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc"
integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==
p-each-series@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/p-each-series/-/p-each-series-1.0.0.tgz#930f3d12dd1f50e7434457a22cd6f04ac6ad7f71"
@ -9422,6 +9530,11 @@ prepend-http@^1.0.0:
resolved "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"
integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=
prepend-http@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=
prettier@1.16.3:
version "1.16.3"
resolved "https://registry.npmjs.org/prettier/-/prettier-1.16.3.tgz#8c62168453badef702f34b45b6ee899574a6a65d"
@ -10018,7 +10131,7 @@ request-promise-core@1.1.3:
dependencies:
lodash "^4.17.15"
request-promise-native@^1.0.5, request-promise-native@^1.0.7, request-promise-native@^1.0.8:
request-promise-native@^1.0.5, request-promise-native@^1.0.7:
version "1.0.8"
resolved "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.8.tgz#a455b960b826e44e2bf8999af64dff2bfe58cb36"
integrity sha512-dapwLGqkHtwL5AEbfenuzjTYg35Jd6KPytsC2/TLkVMz8rm+tNt72MGUWT1RP/aYawMpN6HqbNGBQaRcBtjQMQ==
@ -10107,6 +10220,13 @@ resolve@1.x, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.11.0,
dependencies:
path-parse "^1.0.6"
responselike@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7"
integrity sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=
dependencies:
lowercase-keys "^1.0.0"
restore-cursor@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
@ -11315,6 +11435,11 @@ to-object-path@^0.3.0:
dependencies:
kind-of "^3.0.2"
to-readable-stream@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771"
integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==
to-regex-range@^2.1.0:
version "2.1.1"
resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38"
@ -11647,6 +11772,13 @@ url-loader@^2.3.0:
mime "^2.4.4"
schema-utils "^2.5.0"
url-parse-lax@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c"
integrity sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=
dependencies:
prepend-http "^2.0.0"
url@^0.11.0:
version "0.11.0"
resolved "https://registry.npmjs.org/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1"