Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@shelf/jest-mongodb does not work with TypeScript #191

Closed
francesco-albanese opened this issue Mar 2, 2020 · 6 comments
Closed

@shelf/jest-mongodb does not work with TypeScript #191

francesco-albanese opened this issue Mar 2, 2020 · 6 comments

Comments

@francesco-albanese
Copy link

francesco-albanese commented Mar 2, 2020

Here the config I am using for jest in jest.config.js:

module.exports = {
  transform: {
    '^.+\\.jsx?$': 'babel-jest',
    '^.+\\.ts?$': 'ts-jest'
  },
  rootDir: './lib',
  roots: ['<rootDir>'],
  moduleFileExtensions: ['ts', 'js', 'json', 'node'],
  preset: "@shelf/jest-mongodb"
};

Jest fails to run tests just saying "Determining test suites to run..."

Works if I replace preset: "@shelf/jest-mongodb" with preset: "ts-jest"

@asciidisco
Copy link

asciidisco commented Mar 3, 2020

We use it with a Typescript setup, our jest.config.js looks like this:

const { defaults: tsjPreset } = require('ts-jest/presets')

module.exports = {
  preset: '@shelf/jest-mongodb',
  // ...some other non related config values...
  transform: tsjPreset.transform,
}

// EDIT: But as you see, we're not using babel, so you might need to configure ts-jest differently, in order to pick up your babel preset: Maybe this helps - https://kulshekhar.github.io/ts-jest/user/config/babelConfig

@francesco-albanese
Copy link
Author

Actually I copy pasted the stuff about babel from another project, this is a node project strictly so there is no need to use babel-jest.

I replaced the configuration with this:

const { defaults: tsjPreset } = require('ts-jest/presets')

module.exports = {
  transform: tsjPreset.transform,
  rootDir: './lib',
  roots: ['<rootDir>'],
  moduleFileExtensions: ['ts', 'js', 'json', 'node'],
  preset: "@shelf/jest-mongodb"
};

but still does not work. Keeps on saying "Determining test suites to run..."

@francesco-albanese
Copy link
Author

Never mind, it was just the Docker image node:alpine which apparently is not compatible with mongodb-memory-server

@chanced
Copy link

chanced commented Jul 9, 2020

@francesco-albanese You left this issue open. Sounds like you should be able to close it.

@gervasioartur
Copy link

I was having same error on Ubuntu 22, i just tried with a different OS like windows and it worked.

@Arcanorum
Copy link

I was having same error on Ubuntu 22, i just tried with a different OS like windows and it worked.

Probably related: #351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants