P
P
plot_pa1232022-03-30 11:58:15
JavaScript
plot_pa123, 2022-03-30 11:58:15

Error when testing a Vue component with Jest in a component using jquery because of this I get a ReferenceError: $ is not defined?

62441b7eb3e1d511577755.png

Here is the error in the console

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
plot_pa123, 2022-04-01
@plot_pa123

Guys, I'm sorry, I found a solution. I'm not fully familiar with the jest library. Because it doesn't use webpack. I added the setup.js file and connected JQuery and other necessary libs there. After I wrote the following in jest.config.js

setupFilesAfterEnv: [
        "<rootDir>tests/js/setup.js"
    ]

This is how I solved this problem
62467592b259c936092152.png

A
Anton Shamanov, 2022-03-30
@SilenceOfWinter

well, import jQuery, what's the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question