I am testing a Angular 7 component which has importing JS modules like:
component.ts
import classA from '../../classA'; // Imported JS modules
export class component implements OnInit {
public a = new classA(10); // Instantiate
...
}
classA.js
class classA {
constructor (a) {
this.max = a;
...
}
module.exports = classA;
component.spec.ts
import classA from '../../classA';
I am importing classA as what I did in component.ts.
This gives an error: TypeError: UndoRedo is not a constructor
I tried to include it in karma.conf.js like:
module.exports = function (config) {
config.set({
...
files: [
"../app/classA.js"
]
});
};
But still get same error. Anyone has any idea how to import JS modules in unit testing?
Aucun commentaire:
Enregistrer un commentaire