How do I import the createSpyObj
property from jasmine?
I have installed @types/jasmine
and jasmine-core
via npm.
I have tried importing jasmine as:
import jasmine from 'jasmine;
import { createSpyObj } from 'jasmine'; //triggers import error in IDE
import * as jasmine from 'jasmine'; //triggers import error in IDE
None of these allow me to access the createSpyObj
without an error thrown in my WebStorm IDE.
More information:
I see a namespace declaration for createSpyObj
in the typings file. It is nested in the jasmine
namespace. This is unlike expect
, it
, which are global declarations, but shouldn't I be able to access it with jasmine.createSpyObj
?
Related, but not duplicate of
How to import 'describe', 'expect' and 'it' into a typescript tests for IDE to not to highlight them and
Unit testing using Jasmine and TypeScript
jasmine uses require syntax, so you must too.
import createSpyObj = jasmine.createSpyObj;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With