From 660ab37bff1c3150203e745f605ed876012f8469 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 14 Nov 2018 19:35:00 +0000 Subject: [PATCH] fix(tests): make assets in test consistent with build --- babel.config.js | 6 +++++- test/fixtures/with-config/layouts/default.vue | 14 -------------- .../with-config/layouts/desktop/default.vue | 14 -------------- .../with-config/layouts/mobile/default.vue | 14 -------------- test/fixtures/with-config/pages/index.vue | 7 +++++++ test/unit/modern.server.test.js | 8 ++++---- 6 files changed, 16 insertions(+), 47 deletions(-) diff --git a/babel.config.js b/babel.config.js index 00e49276e9..a6f2bd372a 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,5 +1,9 @@ +function isBabelLoader(caller) { + return caller && caller.name === 'babel-loader' +} + module.exports = function (api) { - if (api.env('test')) { + if (api.env('test') && !api.caller(isBabelLoader)) { return { presets: [ ['@babel/env', { diff --git a/test/fixtures/with-config/layouts/default.vue b/test/fixtures/with-config/layouts/default.vue index f89869bff1..f1670a7a2d 100644 --- a/test/fixtures/with-config/layouts/default.vue +++ b/test/fixtures/with-config/layouts/default.vue @@ -4,17 +4,3 @@ - - diff --git a/test/fixtures/with-config/layouts/desktop/default.vue b/test/fixtures/with-config/layouts/desktop/default.vue index e516aa2469..649ec36e41 100644 --- a/test/fixtures/with-config/layouts/desktop/default.vue +++ b/test/fixtures/with-config/layouts/desktop/default.vue @@ -4,17 +4,3 @@ - - diff --git a/test/fixtures/with-config/layouts/mobile/default.vue b/test/fixtures/with-config/layouts/mobile/default.vue index 406ee00dc9..7219975d14 100644 --- a/test/fixtures/with-config/layouts/mobile/default.vue +++ b/test/fixtures/with-config/layouts/mobile/default.vue @@ -4,17 +4,3 @@ - - diff --git a/test/fixtures/with-config/pages/index.vue b/test/fixtures/with-config/pages/index.vue index 4655686e0f..202ed3e9f6 100644 --- a/test/fixtures/with-config/pages/index.vue +++ b/test/fixtures/with-config/pages/index.vue @@ -9,4 +9,11 @@ ::placeholder { color: black; } +@font-face { + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(~assets/roboto.woff2) format('woff2'); + unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; +} diff --git a/test/unit/modern.server.test.js b/test/unit/modern.server.test.js index e3a5fe2947..d43bc99ff5 100644 --- a/test/unit/modern.server.test.js +++ b/test/unit/modern.server.test.js @@ -1,4 +1,4 @@ -import { loadFixture, getPort, Nuxt, rp } from '../utils' +import { loadFixture, getPort, Nuxt, rp, wChunk } from '../utils' let nuxt, port const url = route => 'http://localhost:' + port + route @@ -28,13 +28,13 @@ describe('modern server mode', () => { }) test('should include es6 syntax in modern resources', async () => { - const response = await rp(url('/_nuxt/modern-app.js')) + const response = await rp(url(`/_nuxt/modern-${wChunk('pages/index.js')}`)) expect(response).toContain('arrow:()=>"build test"') }) test('should not include es6 syntax in normal resources', async () => { - const response = await rp(url('/_nuxt/app.js')) - expect(response).not.toContain('arrow:()=>"build test"') + const response = await rp(url(`/_nuxt/${wChunk('pages/index.js')}`)) + expect(response).toContain('arrow:function(){return"build test"}') }) // Close server and ask nuxt to stop listening to file changes