blakeembrey / sql-template-tag

ES2015 tagged template string for preparing SQL statements, works with `pg`, `mysql`, and `sqlite`

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot find module error when using sql-template-tag within jest

danielc92 opened this issue · comments

I'm getting 'cannot find module' error in jest

Screenshot from 2023-01-27 15-02-34

jest config

module.exports = {
  preset: 'ts-jest',
  testTimeout: 10000,
  testEnvironment: 'node',
  automock: false,
  collectCoverage: true,
  coverageDirectory: './coverage',
  collectCoverageFrom: [
    'src/**/*.ts',
    '!src/**/*.d.ts',
    '!jest.config.js',
    '!webpack.config.js'
  ],
  testMatch: ['**/?(*.)+(spec|test).ts'],
  moduleNameMapper: {
    '<rootDir>/src/config': '<rootDir>/src/__mocks__/config.js'
  },
  moduleDirectories: [
    'node_modules',
    'src'
  ]
};

This appears to be an issue with either Jest or TS Jest, not my module, so those might be better places to ask questions. This looks the same as this question: https://stackoverflow.com/questions/66154478/jest-ts-jest-typescript-with-es-modules-import-cannot-find-module

If you are unable to use ES modules in your setup, I recommend using the previous major release of the package that was written for CommonJS instead.