• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

150
Views
vue-cli-service test:unit trigger an "Unexpected token" on `...` (spread operator)

on my code i'm using ... (destructure operator). but i got "Unexpected token" on module build phase, i don't know how to fix this issue ? (beside rewrite my code in a way without using ... operator)

i use vue-cli-service test:unit src/**/*.spec.js to run tests,

package.json:

    ...
    "devDependencies": {
        "@vue/cli-plugin-babel": "^3.12.1",
        "@vue/cli-service": "^4.5.9",
        "babel-plugin-transform-runtime": "^6.23.0",
        "babel-cli": "^6.26.0",
        ...
    },
    ...

enter image description here

about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To fix this problem i've needed to install @babel/preset-env and set it on babel.config.js (in my case) or .babelrc

presets: [
    [
        '@babel/preset-env',
        {
            targets: {
                esmodules: true,
            },
        }
    ]
],

source of solution is this github comment

also targets.esmodules in depth

about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error