From 63520aa337519ff3161a790abe55377699a11492 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sun, 6 May 2018 20:29:59 +0100 Subject: [PATCH] test: build.transpile --- test/fixtures/with-config/nuxt.config.js | 1 + test/unit/basic.dev.test.js | 29 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/test/fixtures/with-config/nuxt.config.js b/test/fixtures/with-config/nuxt.config.js index 81891cfb67..68d5d8b53f 100644 --- a/test/fixtures/with-config/nuxt.config.js +++ b/test/fixtures/with-config/nuxt.config.js @@ -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' diff --git a/test/unit/basic.dev.test.js b/test/unit/basic.dev.test.js index 4faf2703f2..44b98fcc7f 100644 --- a/test/unit/basic.dev.test.js +++ b/test/unit/basic.dev.test.js @@ -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'))