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.

Usage from Jest in Typescript

See original GitHub issue

The 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:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jellingcommented, Oct 8, 2018

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.

0reactions
JamieMasoncommented, May 10, 2018

perfect 👍

Read more comments on GitHub >

github_iconTop 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 >

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