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

wrong message: Expected e to be of type .... - instead of Expected argument to be of type #236

Open
pmunin opened this issue Mar 11, 2022 · 3 comments

Comments

@pmunin
Copy link

pmunin commented Mar 11, 2022

Simple code:

ow([123], 'myValues', ow.array.ofType(ow.string))

All of a sudden started giving me the following error message:

'(array `myValues`) Expected `e` to be of type `string` but received type `number`'

Previously it was giving me the right message

'(array `myValues`) Expected argument to be of type `string` but received type `number`'

This behavior happens during jest test run.

The changes I made in my package.json/devDependencies:

- "jest": "^26.6.3",
+ "jest": "^27.5.1",

-  "@types/jest": "^24.0.11",
+  "@types/jest": "^27.4.1",

-  "ts-jest": "^26.5.5",
+ "ts-jest": "^27.1.3",

@sindresorhus
Copy link
Owner

Are you minifying the code? e sounds like a minified identifier.

@pmunin
Copy link
Author

pmunin commented Mar 11, 2022

It does look like minifier, but I didn't change anything else in my configs. And once I rolled back those dependencies (jest + ts-ject) to older versions - it started working fine again. So it's obviously the problem in ts-jest.

Here is my jest.config:

module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  modulePathIgnorePatterns: ['<rootDir>/dist/'],
  moduleNameMapper: {
    '@/(.+)': '<rootDir>/src/$1'
  },
  clearMocks: true,
  resetMocks: true,
  testMatch: ['**/tests/**/*.[jt]s?(x)', '<rootDir>/src/**/*.test.ts'],
  testPathIgnorePatterns: ['<rootDir>/tests/helpers', '<rootDir>/tests/fixtures', '<rootDir>/tests/dbaccess', '<rootDir>/tests/setupTests.ts'],
  setupFilesAfterEnv: ['<rootDir>/tests/setupTests.ts'],
  testTimeout: 30000
}

here is my tsconfig.json:

{
  "extends": "@sindresorhus/tsconfig",
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2018",
    "esModuleInterop": true,
    "sourceMap": true,
    "outDir": "dist",
    "baseUrl": "./src",
    "paths": {
      "@/*": ["./*"]
    },
    "noUncheckedIndexedAccess": false,
    "noPropertyAccessFromIndexSignature": false
  },
  "exclude": ["node_modules", "dist"],
  "include": ["src"]
}

@bgornicki
Copy link

I experience similar problem in mocha unit tests (will check if it also affects production code) - seeing wrong argument name in error message.

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

No branches or pull requests

3 participants