Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

207
Vistas
Vue: Mixin in Unit Test causes weird test failure

I am attempting to add some unit tests to a component that has a mixin.

Here is roughly what the mixin is doing:

import test from '@/assets/file.txt'

export default {
  data() {
    return {
      title: '',
      body: ''
    }
  },
  methods: {
    initData() {
      // Read data from the file and update data() above.
    }
  }
}

The only seemingly relevant line in this mixin causing the error is the import. It is throwing a SyntaxError as follows:

SyntaxError: Invalid left-hand side expression in prefix operation

> 1 | import alertTuning from '@/assets/AlertTuning.md'
    | ^
  2 |
  3 | export default {
  4 |   data() {

  at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
  at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
  at Object.<anonymous> (src/assets/js/mixins/alertTuningTemplateMixin.js:1:1)

This strikes me as weird because I know this is syntactically correct JavaScript, why would this import be throwing such an error only when unit testing it?

The mixin works perfectly outside of testing scenarios, i.e. in our local, prod, and stage website it works perfectly without any errors.

Thanks.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda