Usage from Jest in Typescript
See original GitHub issueThe documentation mentions adding the following to spec files to get the added matchers:
import JasmineExpect from 'jasmine-expect';
However this does not work as expected with my combination of packages (should be current latest at time of writing):
- typescript: 2.8.3
- jest: 22.4.3
- jasmine-expect: 3.8.3
The snippet above gives the error: “…/node_modules/jasmine-expect/jasmine-matchers.d.ts is not a module”. If I copy the .d.ts file into my repo root folder and change the namespace declaration from jasmine
to jest
and remove the import
statement, then the problem goes away.
I’m not actually sure how this should be resolved, short of repeating the declare namespace
for jasmine and jest. Personally, I think it’s a little silly that jest is “rebranding” the jasmine namespace 😕
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Getting Started - Jest
ts-jest is a TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript.
Read more >Testing TypeScript apps using Jest - LogRocket Blog
Jest is a simple, lightweight testing framework that provides a variety of testing capabilities to JavaScript and TypeScript projects. It ...
Read more >Jest - TypeScript Deep Dive - Gitbook
Step 1: Install ; Install jest framework ( jest ) ; Install the types for jest ( @types/jest ) ; Install the TypeScript...
Read more >Setting up a project with jest in TypeScript. - ITNEXT
ts-jest is a TypeScript preprocessor for jest , that lets you use jest to test projects written in TypeScript.
Read more >How to Test TypeScript with Jest - Medium
In this post, I will show the necessary steps to test your TypeScript code using a popular JavaScript testing framework Jest and also...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please update the homepage to include the example code provided by LarsImNetz, specifcally using
import "jasmine-expect";
. Also it is no longer necessary to get the @types since they’re included.perfect 👍