test: build.transpile

This commit is contained in:
Clark Du 2018-05-06 20:29:59 +01:00
parent 8b0c2f1a67
commit 63520aa337
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9
2 changed files with 20 additions and 10 deletions

View File

@ -62,6 +62,7 @@ export default {
return null // Coverage: Return null, so defaults will be used.
}
},
transpile: 'vue-test',
extend(config, options) {
return Object.assign({}, config, {
devtool: 'nosources-source-map'

View File

@ -4,6 +4,7 @@ let port
const url = route => 'http://localhost:' + port + route
let nuxt = null
let transpile = null
describe('basic dev', () => {
beforeAll(async () => {
@ -12,23 +13,31 @@ describe('basic dev', () => {
debug: true,
buildDir: '.nuxt-dev',
build: {
stats: 'none'
stats: 'none',
transpile: [
'\\vue.test\\.js',
/vue-test/
],
extend({ module: { rules } }, { isClient }) {
if (isClient) {
const babelLoader = rules.find(loader => loader.test.test('.jsx'))
transpile = babelLoader.exclude
}
}
}
})
nuxt = new Nuxt(config)
new Builder(nuxt).build()
await new Builder(nuxt).build()
port = await getPort()
await nuxt.listen(port, 'localhost')
})
// TODO: enable test when style-loader.js:60 was resolved
// test.serial('/extractCSS', async t => {
// const window = await nuxt.renderAndGetWindow(url('/extractCSS'))
// const html = window.document.head.innerHTML
// t.true(html.includes('vendor.css'))
// t.true(!html.includes('30px'))
// t.is(window.getComputedStyle(window.document.body).getPropertyValue('font-size'), '30px')
// })
test('Config: build.transpile', async () => {
expect(transpile('vue-test')).toBeUndefined()
expect(transpile('node_modules/test.js')).toBe(true)
expect(transpile('node_modules/vue-test')).toBe(false)
expect(transpile('node_modules/test.vue.js')).toBe(false)
})
test('/stateless', async () => {
const window = await nuxt.renderAndGetWindow(url('/stateless'))