Categories
Mastering Development

How to fix vue-jest error – SyntaxError: Unexpected token ‘export’

How to fix vue-jest error – SyntaxError: Unexpected token ‘export’? I’m having an issue with vue-jest unit test. Any help will be appreciated. 1. jest.config.js module.exports = { preset: ‘@vue/cli-plugin-unit-jest/presets/no-babel’, "moduleFileExtensions": [ "js", "ts", "json", "vue" ], transform: { ‘.*\\.(vue)$’: ‘<rootDir>/node_modules/vue-jest’ }, } 2. package.json { "name": "hotel-frontend-vue", "version": "0.1.0", "private": true, "scripts": { "serve": […]

Categories
Mastering Development

(Vue.js | Jest | Babel) Unexpected token when importing specific vue file

I’m importing a vue file with just scripts in vue file with only template tag And then I import js files to help me to do what I need In this last imports are the problem (I think), but is just this file, because I already tested with another ones and test passes PS: sorry […]

Categories
Mastering Development

Issue trying to setup jest: application code compiles fine but test code doesn’t

I am trying to migrate to jest and I am facing typescript issues… I have 3 tsconfig files: tsconfig.json (base config) tsconfig.lib.json (application config) tsconfig.jest-spec.json (jest-dedicated test config) Please note that there are also karma/jasmine dedicated tsconfig files but those are irrelevant. I have separated the jest tests from the karma ones. tsconfig.json { "compileOnSave": […]

Categories
Mastering Development

How to setup jest with node_modules that use es6

I have a very simple test: describe(‘sanity’, () => { it(‘sanity’, () => { expect(true).toBeTruthy() }) }) And I’m receiving the following error: FAIL spec/javascript/sanity_test.js ● Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it’s not plain […]