test: resolvePath throws error

This commit is contained in:
Clark Du 2018-01-29 11:41:56 +08:00
parent a2ac4cb331
commit 4907e81574
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9
2 changed files with 9 additions and 3 deletions

View File

@ -200,9 +200,7 @@ module.exports = class Nuxt {
})
return resolvedPath
} catch (error) {
if (error.code === 'MODULE_NOT_FOUND') {
// Continue to try other methods
} else {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error
}
}

View File

@ -78,6 +78,14 @@ test.serial('Deprecated: dev in build.extend()', async t => {
t.true(logSpy.calledWith('[build:done]: hook error'))
})
test.serial('Error: resolvePath()', async t => {
let error = t.throws(() => nuxt.resolvePath())
t.true(error instanceof TypeError)
error = t.throws(() => nuxt.resolvePath('@/pages/about.vue'))
t.true(error.message.includes('Cannot resolve "@/pages/about.vue"'))
})
// Close server and ask nuxt to stop listening to file changes
test.after.always('Closing server and nuxt.js', async t => {
await nuxt.close()