question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use with Jest ?

See original GitHub issue

version: 0.4.5

// MyComponent.tsx
export default defineComponent({
    // ....
})

// *.spec.ts
it('should render', () => {
    const wrapper = shallowMount(MyComponent)  // throw error: defineComponent is not defined
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
antfucommented, Dec 22, 2021

So I create a tools to (solve) this https://github.com/vitest-dev/vitest 👀

4reactions
Evertvdwcommented, Nov 23, 2021

@zynth17 @Xa3lis @Hyphon I just stumbled upon this as well, but I found a workaround/solution, inside the jest.setup file you can import the composables and set them on global. Like this:

import { useQuasar } from "quasar";
import { useRoute, useRouter } from "vue-router";
import { useStore } from "src/store";
import { computed } from "vue";

global.useQuasar = useQuasar;
global.useRoute = useRoute;
global.useRouter = useRouter;
global.useStore = useStore;
global.computed = computed;

If you use TS you will probably need to disable some type checking because otherwise it will complain that those properties are not defined on Global at runtime.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started - Jest
Install Jest using your favorite package manager: npm; Yarn. npm install --save-dev jest ... To use Babel, install required dependencies:.
Read more >
Jest Tutorial for Beginners: Getting Started With JavaScript ...
Jest is a JavaScript test runner, that is, a JavaScript library for creating, running, and structuring tests. Jest ships as an NPM package,...
Read more >
Jest Tutorial - JavaScript Unit Testing Using Jest Framework
In this Jest tutorial, we will learn about various Jest features, Jest matchers and how to use Jest framework for JavaScript Unit Testing....
Read more >
Introduction To Testing In JavaScript With Jest - YouTube
Testing is one of those things that people either love or hate. Usually testing is something that is hated, until you work on...
Read more >
Testing TypeScript apps using Jest - LogRocket Blog
Jest is a simple, lightweight testing framework that provides a variety of testing capabilities to JavaScript and TypeScript projects. It ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found