arogozine / LinqToTypeScript

LINQ to TypeScript
https://arogozine.github.io/linqtotypescript/
MIT License
140 stars 18 forks source link

"Cannot find module 'linq-to-typescript'" with @testing-library/react #31

Open maxime-aubry opened 5 months ago

maxime-aubry commented 5 months ago

Hello.

When i test a component with @testing-library/react, i get an error "Cannot find module 'linq-to-typescript'..." Could you help me please ?

"linq-to-typescript": "^11.1.0", "@testing-library/jest-dom": "^6.4.5", "@testing-library/react": "^12.1.5", "@testing-library/user-event": "^14.5.2",

maxime-aubry commented 5 months ago

Cannot find module 'linq-to-typescript' from 'src/indirectTime/redux/slices/clientSelectionSlice/service.ts'

Require stack:
  src/indirectTime/redux/slices/clientSelectionSlice/service.ts
  src/indirectTime/redux/slices/clientSelectionSlice/index.ts
  src/indirectTime/redux/reducers/index.ts
  src/indirectTime/redux/store/index.ts
  src/indirectTime/__test__/redux/index.tsx
  src/indirectTime/__test__/components/common/TimesheetColumnMapper/component.test.tsx

> 1 | import { from } from 'linq-to-typescript';
    | ^
  2 | import { ClientHierarchyClientState } from '../../states/clientHierarchyClient.state';
  3 | import { ClientHierarchyLegalEntityState } from '../../states/clientHierarchyLegalEntity.state';
  4 | import { ClientHierarchyRegionBusinessUnitState } from '../../states/clientHierarchyRegionBusinessUnit.state';

  at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
  at Object.<anonymous> (src/indirectTime/redux/slices/clientSelectionSlice/service.ts:1:1)
  at Object.<anonymous> (src/indirectTime/redux/slices/clientSelectionSlice/index.ts:11:1)
  at Object.<anonymous> (src/indirectTime/redux/reducers/index.ts:2:1)
  at Object.<anonymous> (src/indirectTime/redux/store/index.ts:2:1)
  at Object.<anonymous> (src/indirectTime/__test__/redux/index.tsx:5:1)
  at Object.<anonymous> (src/indirectTime/__test__/components/common/TimesheetColumnMapper/component.test.tsx:4:1)
merklegroot commented 5 months ago

I'm running into the same issue with Jest. The library works great outside of Jest.

Cannot find module 'linq-to-typescript' from '__tests__/State/stateAggregator.ts'

> 1 | import { from } from "linq-to-typescript";
    | ^
  2 |
  3 | describe('stateAggregator', () => {
  4 |     it('getStats', () => {

  at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
  at Object.<anonymous> (__tests__/State/stateAggregator.ts:1:1)
arogozine commented 1 month ago

@merklegroot My unit tests use jest, take a look at jest.config.js