Skip to content

SyntaxError: Unexpected token import on fresh project #1475

Closed
@matrunchyk

Description

@matrunchyk

Version

3.0.0-beta.15

Reproduction link

http://take.ms/A60B9

Steps to reproduce

  1. vue create vue-project
  2. cd vue-project
  3. jest tests/unit/HelloWorld.spec.js --no-cache

What is expected?

The test case is executed with no errors

What is actually happening?

Test suite failed to run


Adding the following block to babel.config.js fixes this particular error

env: {
    test: {
      presets: ['@babel/env'],
    },
  },

but it raises another error:
http://take.ms/jlxuP

And this happens because import doesn't work for some reason.
When I change
import HelloWorld from '@/components/HelloWorld.vue';
to
const HelloWorld = require('../../src/components/HelloWorld.vue').default;
it works fine: http://take.ms/ILHes

P.S. Unaliased import doesn't work as well:

import HelloWorld from '../../src/components/HelloWorld.vue';

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs reproductionThis issue is missing a minimal runnable reproduction, provided by the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions