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

Property 'toBeWithinRange' does not exist on type 'Matchers<void>' #87

Closed
lihaibh opened this issue Oct 4, 2017 · 8 comments
Closed

Comments

@lihaibh
Copy link

lihaibh commented Oct 4, 2017

Ive installed jasmine-expect library in my nodejs application, im using Jest my ide displays an error:
Property 'toBeWithinRange' does not exist on type 'Matchers<void>' and when i run my test suit itself i get an error:
TypeError: expect(...).toBeWithinRange is not a function

Ive installed jasmine-expect and types/jasmine-expect.

My test suits are writen in Typescript, the testing framework im using is Jest, i followed the guide from your Readme.md and it still doesnt work:
configured package.json with:
"jest": { "unmockedModulePathPatterns": [ "jasmine-expect" ] ... }

added to my tsconfig.json with:
"types": [ "node", "jasmine-expect", "jasmine" ], ...

@JamieMason
Copy link
Owner

Hello @lihaibh, thank you for opening this issue. There is an open pull request at #62 (comment) which explains the current status of TypeScript support, unfortunately at the moment it needs improvement.

@JoshuaKGoldberg
Copy link

@lihaibh is this issue resolved? #62 was merged & released :)

@JamieMason
Copy link
Owner

This should hopefully be address in 3.8.3.
Please give that a try and let us know via a comment or by closing the issue, thanks.

@lihaibh
Copy link
Author

lihaibh commented Mar 24, 2018

@JoshuaKGoldberg @JamieMason it still doesnt work, on version: 3.8.3.
Do you have any working sample / existing project that is written in Typesciprt and uses Jest with Jasmine-Matchers?

Also when i add the line at the top of my spec file:

import JasmineExpect from 'jasmine-expect';

I receive the error:

[ts] File '..../node_modules/jasmine-expect/jasmine-matchers.d.ts' is not a module.

so i removed it, but it still doesnt work..

@j5bot
Copy link

j5bot commented Apr 29, 2018

I am converting to Jest from Karma and I moved the import statement to my setup-jest.ts and changed it to:

import 'jasmine-expect';

And my tests are running, no complaints in my IDE (Atom). Even if you aren't willing to convert to Jest you might try just changing the import statement to just import 'jasmine-expect';

@glitchbane
Copy link

glitchbane commented May 1, 2018

I can confirm that adding the line

import 'jasmine-expect';

to the test file does work in Angular 5 with TypeScript.

@JamieMason
Copy link
Owner

Thanks all, in the meantime I am working on a working example at https://github.com/JamieMason/Jasmine-Matchers/tree/dev/examples/jasmine-typescript. I'm not ready to merge it yet but it works. Thanks.

@JamieMason
Copy link
Owner

I think this can be closed 🤞 The Jasmine with TypeScript example is working:

expect(2).toBeWithinRange(1, 3);

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

No branches or pull requests

5 participants