question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property 'toStrictEqual' does not exist on type 'Matchers<any>'

See original GitHub issue

Bug

  • package version: 0.11.2
  • node version: 12.3.1
  • npm version: 6.11.2
  • typescript version: 3.5.3

Relevant code or config

module.exports = {
    globals: {
        'ts-jest': {
            tsConfig: './src/tsconfig.spec.json',
            stringifyContentPathRegex: '\\.html$',
            astTransformers: [
                require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer')
            ]
        },
    },
    setupFilesAfterEnv: [
        '<rootDir>/node_modules/@angular-builders/jest/dist/jest-config/setup.js',
        'jest-extended',
    ],
    transform: {
        '^.+\\.(ts|js|html)$': 'ts-jest'
    },
    testMatch: [
        '**/__tests__/**/*.+(ts|js)?(x)',
        '**/+(*.)+(spec).+(ts|js)?(x)'
    ],
    testEnvironment: 'jest-environment-jsdom-thirteen',
    moduleFileExtensions: ['ts', 'js', 'html'],
    moduleNameMapper: {
        "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/test/mocks/files-mock.js",
        "\\.(css|scss)$": "<rootDir>/test/mocks/styles-mock.js",
        '^core-js/es6/(.*)': '<rootDir>/././node_modules/core-js/es/$1',
        '^core-js/es7/reflect': '<rootDir>/././node_modules/core-js/proposals/reflect-metadata',
        '^@core/(.*)': '<rootDir>/./src/app/core/$1',
        '^@shared/(.*)': '<rootDir>/./src/app/shared/$1',
        '^@feature/(.*)': '<rootDir>/./src/app/feature/$1',
        '^@test/(.*)': '<rootDir>/./src/app/feature/$1'
    },
    transformIgnorePatterns: ['node_modules/(?!@ngrx)'],
    collectCoverageFrom: [
        '{src|projects}/**/{src|lib}/**/*.{ts}',
        '!{src|projects}/*.{ts}',
        '!{src|projects}/**/*.{js}',
        '!{src|projects}/**/environments/*.{ts}',
        '!{src|projects}/**/model/*.{ts}',
        '!{src|projects}/**/*.module.{ts}',
        '!{src|projects}/**/*public_api.{ts}',
        '!{src|projects}/**/main.{ts}',
        '!{src|projects}/**/polyfills.{ts}',
        '!{src|projects}/**/*index.{ts}',
        '!{src|projects}/**/*test.{ts}',
        '!{src|projects}/**/*.enum.{ts}',
        '!{src|projects}/**/*.state.{ts}',
        '!{src|projects}/**/*.entity.{ts}',
        '!**/**e2e/**/*.{ts}',
        '!**/node_modules/**',
        '!**/vendor/**',
    ],
    moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
    testPathIgnorePatterns: ['/node_modules/', '/dist/', 'src/app/*.{js}'],
    testResultsProcessor: 'jest-sonar-reporter',
    snapshotSerializers: [
        'jest-preset-angular/AngularSnapshotSerializer.js',
        'jest-preset-angular/HTMLCommentSerializer.js'
    ]
};

What you did: I am trying to run a test utilizing a jest-extended matcher function (i.e. toStrictEqual).

What happened (please provide anything you think will help): I cannot get the compiler to recognize jest-extended matchers, no matter what I seem to try; for example: - error TS2339: Property ‘toStrictEqual’ does not exist on type ‘Matchers<any>’.

I have followed everything in the README and here https://github.com/jest-community/jest-extended/issues/172 in order to get the typings to work and they finally seem to work, but I still can’t get the compiler to recognize the matcher functions.

Reproduction repository (if possible):

N/A

What am I missing?

Possibly related to https://github.com/jest-community/jest-extended/issues/171 and https://github.com/jest-community/jest-extended/issues/189 which seem to have been ignored.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

3reactions
jjcv2304commented, Jun 4, 2020

Any updates on this? I’m using “ts-jest”: “^26.1.0”, and also having same issue

1reaction
fidercommented, Aug 14, 2020

@jjcv2304 I just added global to jest config in package.json

{
  "jest": {
    "preset": "ts-jest",
    "testEnvironment": "node",
    "setupFilesAfterEnv": [
      "jest-extended",
      "./tests/tests-setup.ts" // includes import 'jest-extended'
    ],
    "globals": { // this did the job
      "ts-jest": {
        "tsConfig": "tsconfig.json"
      }
    },
    ...
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Property 'toStrictEqual' does not exist on type 'Matchers<any>'
Coming soon: A brand new website interface for an even better experience!
Read more >
reactjs - Property 'toBeInTheDocument' does not exist on type ...
Was facing a problem with toBeVisible() not being found (TS2339: Property 'toBeVisible' does not exist on type 'JestMatchersShape<Matchers<void, ...
Read more >
matcher for jest is not recognized, but it is runable : WEB-42350
matcher is marted as "TS2339: property 'toEndWith' does not exist on type 'Matchers'." Please provide any additional information below.
Read more >
the property tobeinthedocument don't exist in 'htmlelement'.
json "dependencies": { "@types/testing-library__jest-dom": "^5.14.2", ..." }, "devDependencies" ...
Read more >
Expect - Jest
There are a lot of different matcher functions, documented below, to help you test ... test('is NOT within range', () => expect(101).not.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found