Answer the question
In order to leave comments, you need to log in
What is the correct way to export a module with multiple ES6 classes for testing?
Essence:
There is a type code
(() => {
class A {
}
class B extends A {
}
class C extends A {
}
class D {
static foo () {
}
}
let var;
if (D.foo()) {
var = new B;
} else {
var = new C;
}
})();
Answer the question
In order to leave comments, you need to log in
I decided to do this: in resources, instead of a closure (although I have already redone the closure to an ES6 block {...}), there are //start and //end, and all classes have export.
When building, for production, //start and //end are changed to { and }, respectively, by gulp-replace, and they also remove the export before the classes. For a task with tests, this file is copied to the src directory with tests and tests through karma, jasmine and phantomjs access it already there, all classes are exported normally, tests are run.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question