jest-mongodb icon indicating copy to clipboard operation
jest-mongodb copied to clipboard

Validation Error: Preset @shelf/jest-mongodb not found.

Open adamcole123 opened this issue 3 years ago • 2 comments

I'm getting the following validation error:

● Validation Error:

  Preset @shelf/jest-mongodb not found.

  Configuration Documentation:
  https://facebook.github.io/jest/docs/configuration.html

This is what my jest.config.js looks like:

const path = require('path')

module.exports = {
	rootDir: path.resolve(__dirname, '../../'),
	testMatch: ['<rootDir>\\test\\unit\\specs\\**.js'],
	moduleFileExtensions: [
		'js',
		'json',
		'vue'
	],
	moduleNameMapper: {
		'^@/(.*)$': '<rootDir>/src/$1'
	},
	transform: {
		'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
		'.*\\.(vue)$': '<rootDir>/node_modules/vue-jest'
	},
	testPathIgnorePatterns: [
		'<rootDir>/test/e2e',
		'<rootDir>/test/unit/specs/bundle'
	],
	snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
	setupFiles: ['<rootDir>/test/unit/setup'],
	coverageDirectory: '<rootDir>/test/unit/coverage',
	collectCoverageFrom: [
		'src/**/*.{js,vue}',
		'!src/main.js',
		'!src/router/index.js',
		'!**/node_modules/**'
	],
	verbose: true,
	testURL: 'http://localhost/',
	preset: '@shelf/jest-mongodb'
}

I installed @shelf/jest-mongodb with the following command:

npm install @shelf/jest-mongodb --also=dev

Any ideas?

Edit: I have tried deleting node_modules and package-lock.json, this didn't work.

adamcole123 avatar Mar 27 '21 14:03 adamcole123

Duplicated with #121 I let you my example

/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
const tsPreset = require('ts-jest/jest-preset')
const mongoPreset = require('@shelf/jest-mongodb/jest-preset')

module.exports = {
  ...tsPreset,
  ...mongoPreset,
  testEnvironment: 'node',
  modulePathIgnorePatterns: ["<rootDir>/.aws-sam", "<rootDir>/dist"]
}

lopezoscar-dev avatar Aug 03 '21 17:08 lopezoscar-dev

I also got the same error. I was able to resolve it by installing the dependency using yarn even though it was already installed using npm. source

yarn add @shelf/jest-mongodb --dev

ritish78 avatar May 19 '23 07:05 ritish78