#cannot find module

6 messages · Page 1 of 1 (latest)

barren spade
#

Hi, i'm getting the following error while runnning test:
FAIL src/modules/crops/controllers/cropType.service.spec.ts
● Test suite failed to run

src/modules/crops/controllers/cropType.service.spec.ts:1:1 - error TS2304: Cannot find name 'cropType'.

1 cropType.service.spec.ts
  ~~~~~~~~
import { CropTypeService } from '../services/cropType.service';
import { getRepositoryToken } from '@nestjs/typeorm';
import { FindOneOptions, Repository } from 'typeorm';
import { CropType } from '../entities/cropType.entity';
import { Test, TestingModule } from '@nestjs/testing';
import { CropsConnectionService } from './crops.connection.service';
import { identity } from 'rxjs';
import { Crop } from '../entities/crop.entity';
import { Console } from 'console';

cropType.service.spec.ts

what could it be?

barren spade
#

geshem-backend@0.0.1 test
jest

FAIL src/modules/crops/controllers/cropType.service.spec.ts
● Test suite failed to run

src/modules/crops/controllers/cropType.service.spec.ts:1:1 - error TS2304: Cannot find name 'cropType'.

1 cropType.service.spec.ts
  ~~~~~~~~

/home/ishamir99/geshem/geshem-backend/node_modules/expect/build/index.js:194
const innerErr = new JestAssertionError();
^

#

i'm keeping getting those messages and don't understand the root problem

wanton hatch
#

Does jest know how to handle src/ imports? Did you set up the modupeNameMapper for that?

barren spade
#

yes I did

json
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node",
    "moduleNameMapper": {
      "^src/(.*)$": "<rootDir>/$1"
    }
wanton hatch
#

Hmm. Can you get me a minimum reproduction?