Closed doox911-opensource closed 11 months ago
I was able to run the test. To do this, you need to:
installQuasarPlugin
and run it.import { describe, it } from '@jest/globals';
import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-jest';
import { mount } from '@vue/test-utils';
import { Notify } from 'quasar';
import Component from './lib/Component.vue';
import { notify } from './lib/notify';
installQuasarPlugin({ plugins: { Notify } });
describe('Test', () => {
it('Success', async () => {
mount(Component);
notify({ message: 'Success' });
});
});
How can I test Notify without mounting any vue component?
You cannot, you need to mount a component to have Jest working
Check out the examples in here
@IlCallo I have the same problem with vitest. Do I really have to use Notify only with a component?
Yes AFAIK, it's not a Jest limitation, it's a unit-testing limitation You need an active Vue instance, to run and test a component library based on Vue
If you find a way to do so otherwise, I can definitely add a docs page about it
Custom function with Notify:
Test:
Expected: everything is ok.
Result:
packege.json
: