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

203
Views
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
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!