Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular Unit Tests failing due to the missing main entry point #418

Open
anking opened this issue May 1, 2023 · 0 comments
Open

Angular Unit Tests failing due to the missing main entry point #418

anking opened this issue May 1, 2023 · 0 comments

Comments

@anking
Copy link

anking commented May 1, 2023

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant