Hey, vue-test-utils got released and since then I’ve decided to integrate it into my project. I chose the path of Testing SFCs with Jest and followed the guide to integrate it.
Testing SFC’s now works! So long as the component does not import anything from 'quasar'
.
Initially, I ran into the issue of:
Cannot find module 'quasar' from 'Hello-Two.vue'
As per research and asking around, was advised to add an alias to my Jest configuration, which looks like this:
"jest": {
"moduleFileExtensions": [
"js",
"json",
"vue"
],
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/src/$1",
"^quasar$": "<rootDir>/node_modules/quasar-framework"
},
"transform": {
".*\\.(vue)$": "<rootDir>/node_modules/vue-jest",
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
},
"mapCoverage": true,
"snapshotSerializers": [
"<rootDir>/node_modules/jest-serializer-vue"
]
}
Unfortunately, the issue has now mutated to:
SyntaxError: Unexpected token export
in the quasar.esm.js
file

This has been reported multiple times by other users here, here and some mention of it; in the Quasar Gitter chat but unfortunately, there is no definitive answer on how to resolve it and hoping to compile it all here.
Although this post potentially hints at a fix but am unclear how to proceed. As importing from quasar-framework
leads to the same outcome.
I’ve created a git repo to recreate the problem using the Quasar PWA template.
Clone it if you wish and run the quasar test
command to begin the testing process.
-
Hello.vue
-> Hello.spec.js
passes as it do not import any quasar
components.
-
Hello-Two.vue
-> Hello-Two.spec.js
fails, due to SyntaxError: Unexpected token export
as mentioned above. This component also import’s a quasar
component.
Researching this issue in general, it seems to lay with the way babel transpiles such that Jest can understand Quasar. As a result, it is now out of my depth and was hoping someone could provide some insight into how to resolve this?
Thanks!