R
R
Ruslan2019-09-19 11:31:00
JavaScript
Ruslan, 2019-09-19 11:31:00

How to write unittests in javascript?

Hello!
The situation is as follows: I have a javascript project that is compiled using the npm run server () command. Those. there is a package.json file that contains the “vue-cli-service serve” command.
In the project, I have some javascript functions that look like this:

import Axios from 'axios';
export default {
    f1(cb) {
        let x = {};
        cb(x);
    }

    f2(p1,p2) {
        return p1 + p2;
    }
}

I need to somehow organize unit testing of these functions, it is also very desirable that there is a possibility of debugging, and I would also like it to be combined with the tools that I use, namely visual studio (but this is not the most important point)
How exactly is this do? In what files to configure, where to write the test code itself, what are the best (easier) testing environments/frameworks to use?
Thank you.
UPD.
A project is a vue client application that, after compilation, is mounted in the browser. The server part is written in asp.net core, I want to understand how it is possible to run my javascript functions not as part of the entire application, but separately (for example, in unit tests) and be able to debug.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question