D
D
Denis2020-05-03 12:37:58
JavaScript
Denis, 2020-05-03 12:37:58

How to import a module so that it is available to run in QUnit and for Node.js?

Hello

My task is this - there is a js file in which the logic for some actions in the browser is written, everything is written there in JQuery, let's call it base.js. I want to write unit tests for the function in this file. Tests must be run both in the browser in the face of QUnit and in Node to run on TeamCity.

To test JQuery, I found the QUnit library, wrote some tests there, and everything starts in the browser. But in order to run it in Node, I need to write import-export there, and when I do this, everything stops working in the browser and writes an error global failure (1, 0, 1) Source: at Object.onError ( https://code. jquery.com/qunit/qunit-2.9.2.js:4218:5 ).

Ideally, I would not want to add any instructions to the main base.js file at all, for which I want to write tests.

Tell me what I'm doing wrong and in general, did I choose the right path?

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