Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
Obteniendo 'SyntaxError: Token inesperado '<'' -error al intentar ejecutar una prueba de unidad Vue

Intentando extraer una prueba unitaria simple con Jest por primera vez. Estoy probando un método llamado convertTypetoText en mi componente Vue y recibo un error que dice:

Detalles:

 C:\Webprojekti1\mygamecollection\src\components\Main.vue:1 ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){<template> ^ SyntaxError: Unexpected token '<'

Main.spec.js (la prueba):

 import { shallowMount } from '@vue/test-utils'; import Main from '../src/components/Main.vue'; describe('Testing type to text conversion', () => { const wrapper = shallowMount(Main); it('correctly converts from "t" or "f" letter to text', () => { expect(wrapper.vm.convertTypeToText('F')).toBe('Physical_copy'); }) })

Intenté agregar un archivo de configuración de broma con configuraciones de transformación.

broma.config.js:

 const path = require('path'); module.exports = { rootDir: path.resolve(__dirname, '../../'), moduleFileExtensions: [ 'js', 'vue', 'html' ], preset: '@vue/cli-plugin-unit-jest', transformIgnorePatterns: [ "/src/(?!mygamecollection)" ], testPathIgnorePatterns: [ "<rootDir>/src/" ], modulePaths: [ "<rootDir>" ], moduleNameMapper: { '^@/(.*)$': '<rootDir>/src/$1', }, transform: { '^.+\\.js$': '<rootDir>/node_modules/babel-jest', '.*\\.vue$': '<rootDir>/node_modules/vue-jest', "^.+\\.html$": "<rootDir>/test/utils/htmlLoader.js" }, testMatch: [ '<rootDir>/(test/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx))' ] }

Lo siento si esto fue incomprensible o algo así. Estoy bastante perdido con Vue.

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

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!