Answer the question
In order to leave comments, you need to log in
How to test in Webpack?
If I start messing with webpack, nothing will work in any way. It's already a rule.
In short, the essence of the problem is that I need to test with Mocha and Chai functions. How can I import them into the test file itself? For example, I have a pow function in a typescript file:
module.exports = {
pow(num: number, extent: number): number {
return num ** extent;
},
};
const plugin = require('../../../dist/assets/js/jquery.slider.min.js');
const mocha = require('mocha');
const chai = require('chai');
const { expect, assert } = chai;
describe('pow', () => {
it('возводит в степень n', () => {
assert.equal(plugin.pow(2, 3), 8);
});
});
1) pow
возводит в степень n:
TypeError: plugin.pow is not a function
at Context.it (src/plugin/tests/tests.js:9:25)
Answer the question
In order to leave comments, you need to log in
Found a simple solution, now tests on ts:
https://journal.artfuldev.com/unit-testing-node-ap...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question