I have tried several days ,but still error, this is my problem :
Cannot find module '../src/repository/UserRoleRepository.js' from 'test/user_roles_positive.test.js'
at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:425:11)
at async Promise.all (index 3)
this is the import section :
import {jest} from '@jest/globals';
import UserRoleRepository from '../src/repository/UserRoleRepository.js';
import UserRoleService from '../src/service/UserRoleService.js';
import validation from '../src/validation/index.js';
const repository = new UserRoleRepository();
const service = new UserRoleService(repository, validation);
jest.mock('../src/repository/UserRoleRepository.js');
this my config.json :
{
"name": "user_role_service",
"type": "module",
"version": "1.0.0",
"description": "service for handling all about logic user role",
"main": "server.js",
"scripts": {
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
"dev": "nodemon ./src/server.js"
},
"jest": {
"transform": {
"^.+\\.[t|j]sx?$": "babel-jest"
}
},
"author": "me",
"license": "ISC",
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.19.1",
"@babel/preset-env": "^7.19.4",
"babel-jest": "^29.2.0",
"dotenv": "^16.0.3",
"eslint": "^8.29.0",
"eslint-config-google": "^0.14.0",
"jest": "^29.2.0",
"nodemon": "^2.0.20",
"prisma": "^4.4.0"
},
"dependencies": {
"@hapi/hapi": "^20.2.2",
"@hapi/nes": "^13.0.0",
"@prisma/client": "^4.4.0",
"joi": "^17.6.2",
"uuid": "^9.0.0"
}
}
this is my babel.config.json :
{
"presets": ["@babel/preset-env"],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"regenerator": true
}
]
]
}
i tried to change the test script in to several code but still error,hope u guys could help me thanks