Tks @paul, i saw ur tests but, they working whitout any import of quasar.
The problem is when import anything from quasar-framework.
From the error i undertand : babel is transpiling my tests ( so i can es6 free in spesc.*) but not transpiling node_modules

Hi @leon ,
Did you successfully managed to configure jest?
I followed that article 1 to setup jest, but I’m stuck with a Cannot find module 'quasar' from 'Messenger.vue' error raised when running npm run unit. Any tip to fix it?
Thanks

@zyegfryed so I ran into the same thing had to add an alias into jest such that it looks like this:"jest": { "moduleNameMapper": { "^@/(.*)$": "<rootDir>/src/$1", "^quasar$": "<rootDir>/node_modules/quasar-framework" }, }

Unfortunately, now I run into the same thing @leon did.SyntaxError: Unexpected token export

However, attempting the method of:import { QBtn } from 'quasar-framework'
did not work for me and am still getting the same export error.

@jaxon I am having the same problem. I am new to the framework but I am thinking if we can have a file that does not use the es6 constructs and do the moduleNameWrapper for it it should work. However, the quasar.esm.js file which is the closest thing there at the moment uses es6 constructs just at the end namely the export

If that portion was translated via babel to the following, it will allow you to move further in your testing.

Hi @trajano
This variable are set in quasar webpack configs. On tests i didint get it, but even whitout him, quasar works, some problems that work is ( no iconsets, no css based on theme etc)
Can you post the component / test ?

I ran into TypeError: Cannot read property 'theme' of undefined as well. My error stack was pointing a problem with quasar.esm.js, where I found out ctx.parent.$q.theme couldn’t be resolved. Possible explanation : this may be related to the fact that my tested component is rendered without its parent component, so ctx.parent doesn’t exist.

Anyway, fortunately I’m using vue-test-utils, which provides “mocks” mounting option, where I set $q: { theme : "mat"}. This works for me, I hope it will help some people here too.

I totally agree that it would be more than welcome to have jest pre-configrued in the boilerplate, @rstoenescu.

By the way, thank you so much for what you’re doing, it’s impressive and a pleasure to work with. I’m building a public website right now, it’s in french, but when it’s translated to english, I’ll give you the link to add to the “made with Quasar” list, if you like

I finally gave up unit testing my Quasar app, too complicated to set up
I chose rather to e2e-test it. Pros and cons for each test type, but I’m using TestCafe, and it took me a few minutes to install, and a few more to run my first test.

There is even a plugin called testcafe-vue-selectors which allows asserting props, data and computed properties. Furthermore, mocking HTTP calls is on TestCafe roadmap (nock is a workaround in the meantime). Both of these points allow some of what unit tests have to offer.

My point is : I’m not convinced it’s worth putting so much effort in unit testing Quasar apps, overall, considering how easy and what can be achieved with e2e testing, TestCafe in particular.