Haste module map error with @angular/cli libraries
See original GitHub issueThe library is generated by ng g library @itrulia/dates
The name `@itrulia/dates` was looked up in the Haste module map. It cannot be resolved, because there exists several different files, or packages, that provide a module for that particular name and platform. The platform is generic (no extension). You must delete or blacklist files until there remains only one of these:
* `/home/talleane/Documents/@itrulia/dates/dist/itrulia/dates/package.json` (package)
* `/home/talleane/Documents/@itrulia/dates/projects/itrulia/dates/package.json` (package)
dist is the generated output by ng build @itrulia/dates
.
spec looks like this:
import {ReactiveFormsModule} from "@angular/forms";
import {async, ComponentFixture, TestBed} from "@angular/core/testing";
import {AppComponent} from "./app.component";
import {DatesModule} from "@itrulia/dates";
describe("AppComponent", () => {
let component: AppComponent;
let fixture: ComponentFixture<AppComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports: [
DatesModule,
ReactiveFormsModule
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it("should create", () => {
expect(component).toBeTruthy();
});
});
I have tried adding
modulePathIgnorePatterns: [
"<rootDir>/projects"
],
This resulted in to Jest not being able to find @itrulia/dates.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top Results From Across the Web
Error: jest-haste-map: Haste module naming collision
The error you get indicates that you have two react-native dependencies. One in your main project, ...
Read more >stryker-mutator/stryker - Gitter
When I run stryker run , I've got the following error message: ... jest --updateSnapshot jest-haste-map: Haste module naming collision: vehicle-dashboard ...
Read more >haste module naming collision: the following files share their ...
I am getting the jest-haste-map issue after doing following steps: ... To Reproduce 1) amplify add function 2) function is created locally correctly...
Read more >Javascript – the Haste module map in node.js - iTecNote
I have an error which says that : Unable to resolve module `util` from `/Users/canatac/RNProjects/<MyProject>/node_modules/<A_Module>/lib/Bot.js ...
Read more >Configuring Jest
Jest will run .mjs and .js files with nearest package.json 's type field set to module as ECMAScript Modules.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I fixed this issue by excluding
dist
dir inmodulePathIgnorePatterns
and mapping packages from@myscope
todist
folder:No, actually in my opinion this is more like user specific requirements and
Jest
config can help you to handle that. The preset doesn’t take into account of it but only helps to setup base configuration to useJest
with anAngular
project. It is similar to the case of configuring paths intsconfig.json
.For example in my current work project, I did this in
tsconfig.json
:and in my
Jest
configuration I put this:This will help
Jest
to resolve the path correctly for the tests.Can you try something similar like that ?