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.

Does not exist on type 'Matchers'

See original GitHub issue

My tests keep failing because it can’t find the matchers for some reason, am I missing something in the installation? I’ve also installed karma-jasmine-matchers but no luck.

I’ve added the following devDependencies: "karma-jasmine-matchers": "^3.7.0" "@types/jasmine": "2.5.45" "@types/jasmine-matchers": "^0.2.30" "jasmine-core": "~2.6.2" "jasmine-expect": "^3.7.0" "jasmine-spec-reporter": "~4.1.0" "karma": "~1.7.0" "karma-chrome-launcher": "~2.1.1" "karma-cli": "~1.0.1" "karma-coverage-istanbul-reporter": "^1.2.1" "karma-jasmine": "~1.1.0" "karma-jasmine-html-reporter": "^0.2.2" "karma-jasmine-matchers": "^3.7.0"

karma.conf.js

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli', 'jasmine-matchers'],
    plugins: [
        'karma-jasmine',
        'karma-chrome-launcher',
        'karma-jasmine-html-reporter',
        'karma-coverage-istanbul-reporter',
        '@angular/cli/plugins/karma',
        'karma-jasmine-matchers'
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

test.spec.ts

import { TestBed, async } from '@angular/core/testing';

import { CoreModule } from '../../core/core.module';
import { ExampleService } from '../../services/example.service';
import { ExampleComponent } from './example.component';

describe('ExampleComponent', () => {
    beforeEach(async(() => {
        TestBed.configureTestingModule({
            declarations: [
                ExampleComponent
            ],
            imports: [ CoreModule ],
            providers: [ ExampleService ]
        }).compileComponents();
    }));

    it('should create the example component', async(() => {
        const fixture = TestBed.createComponent(ExampleComponent);
        const app = fixture.debugElement.componentInstance;
        expect(app).toBeTruthy();
    }));

   // It fails here
    it('should be an array', async(() => {
        const test = [true, false, false, false];
        expect(test).toBeArrayOfBooleans();
    }));
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
e11encommented, Jun 21, 2017

@mvaljento , nope I haven’t figured it out yet. I’m just waiting for the people that JamieMason tagged.

1reaction
mvaljentocommented, Jun 21, 2017

@e11en , any luck so far?

I ran into similar trying to get “jasmine-expect” matchers to work with Protractor and it’s driving me nuts. I’ve added references/require statements to karma.conf.js and protractor.conf.js, but the problem seems to be that TypeScript compiler does not recognise the custom matchers. When I run the tests with “ng e2e” I get same error:

expect(new Date()).toBeValidDate();

Error: TSError: ⨯ Unable to compile TypeScript e2e/public-events.e2e-spec.ts (39,24): Property 'toBeValidDate' does not exist on type 'Matchers<Date>'. (2339)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Property 'toStrictEqual' does not exist on type 'Matchers<any>'
I am trying to run a test utilizing a jest-extended matcher function (i.e. toStrictEqual). What happened (please provide anything you think will ...
Read more >
Typescript throw error Property 'to' does not exist on type ...
error TS2339: Property 'to' does not exist on type 'Matchers'. I'm new to typescript but I guess I'm missing some type files for...
Read more >
TS2339: Property 'toHaveBeenCalledWith' does not exist on ...
TS2339 : Property 'toHaveBeenCalledWith' does not exist on type 'Assertion'. When doing Angular tests from WebStorm, I keep getting these error notifications ...
Read more >
webdriverio/webdriverio - Gitter
I am getting the following error while running test in typescript. Error: ⨯ Unable to compile TypeScript: src/tests/login.spec.ts(10,31): error TS2339: ...
Read more >
property 'tobeinthedocument' does not exist on type ... - You.com
Property 'toBeInTheDocument' does not exist on type 'JestMatchers<HTMLElement>'. which leads to Cannot use import statement outside a module if you try to add ......
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