Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run test:unit fails on new project. #1524

Closed
kjellkvinge opened this issue Jun 8, 2018 · 4 comments
Closed

npm run test:unit fails on new project. #1524

kjellkvinge opened this issue Jun 8, 2018 · 4 comments
Labels

Comments

@kjellkvinge
Copy link

Version

3.0.0-beta.15

Reproduction link

https://gitlab.com/kjell/vuecli

Steps to reproduce

Run ui. Create a project. choose feature unit testing and jest.

The result of this process is pushed to the repo https://gitlab.com/kjell/vuecli

To reproduce

  git clone https://gitlab.com/kjell/vuecli.git
  cd vuecli/
  npm install --dev
  npm run test:unit

What is expected?

Expect test to pass

What is actually happening?

I get the following error:

Jest encountered an unexpected token
...
Details:
test_cli/tests/unit/HelloWorld.spec.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { shallowMount } from '@vue/test-utils'
                                                                                             ^^^^^^

    SyntaxError: Unexpected token import

I have tested this with beta 15 and beta 16.

Tested on Ubuntu, node v8.11.1

@yyx990803
Copy link
Member

yyx990803 commented Jun 8, 2018

Edit: nvm it seems you removed Babel from the project...
This could be a bug

@yyx990803 yyx990803 added the bug label Jun 8, 2018
@kjellkvinge
Copy link
Author

Thank you.

I am pretty sure I not removed babel on purpose and that Babel was checked in the new project wizard. I tried again now, creating new project. Making sure Jest and babel was chosen, and the same error occurs.

I saved as a preset. Is there any way to export this preset?

@yyx990803
Copy link
Member

Hmm, ok so my commit fixed the issue when Babel was not selected, but it seems you actually wanted Babel.

So it looks more like a problem of creating the project through UI is unintentionally dropping the Babel plugin. That looks like something similar to #1479. /cc @Akryum

@davidkassa
Copy link

I'm received a similar error on and off since -beta.14. I just got it with -rc.1. (below).

The workaround I found here works for me: jestjs/jest#3202 (comment) - delete jest* from your temp dir.

    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import "core-js/modules/es6
.promise";                                                                                                              
                                                                                             ^^^^^^                     
                                                                                                                        
    SyntaxError: Unexpected token import                                                                                
                                                                                                                        
      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:402:17)      

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants