Angular Unit Tests failing due to the missing main entry point
anking opened this issue · 0 comments
When i ran unit tests on files that use import { PickerModule } from '@ctrl/ngx-emoji-mart';
the tests are always failing since the JEST is unable to resolve the emoji module.
I found that it is due to the missing "main" parameter in package.json that suppose to point to the compiled .js file.
Since there is no compiled bundle included JEST is unable to resolve it:
Cannot find module '@ctrl/ngx-emoji-mart'
And all tests are failing. Is there a good workaround for it? Maybe JEST can be configured to pre-build emoji picker before the import?
I was able to fool JEST by adding the following line to the ngx-emoji-mart package.json but its not a long-term solution obviously.
"main": "./test-bundle.js",
test-bundle.js:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var AppModule = /** @class */ (function () {
function AppModule() {
}
AppModule = __decorate([
core_1.NgModule({
imports: [],
declarations: [],
bootstrap: []
})
], AppModule);
return AppModule;
}());
exports.PickerModule = AppModule;