Property 'Ajax' does not exist on type 'typeof jasmine'

380 views
Skip to first unread message

Steve Yoo

unread,
Feb 27, 2018, 11:59:19 PM2/27/18
to Jasmine
Hello,

I am trying to use/add the jasmine-ajax plugin to test ajax calls in my Angular CLI application.  After creating a new project using Angular CLI, I do a "jasmine init".  Then I modify the generated jasmine.json file and add the path to my mock-ajax.js file in the "helpers" section of the file.  After doing so, I require('jasmine-ajax') at the top of my spec file and then proceed to "jasmine.Ajax.install()", however I get the error "Property 'Ajax' does not exist on type 'typeof jasmine' ".  Any thoughts?  I thought this would be a simple installation but am having a lot of difficulty getting it working.  I'm sure it's something small I am missing.

Thanks,
Steve

Steve Yoo

unread,
Feb 27, 2018, 11:59:19 PM2/27/18
to Jasmine
Hello,

I am trying to use the "jasmine-ajax" plugin in my Angular CLI project.  First, I create a new Angular project using the CLI.  Next, I "jasmine init" and add the path to my "mock-ajax.js" file in my node modules in the "jasmine.json" helpers section.  Last, I "require('jasmine-ajax')" at the top of my spec file and then jasmine.Ajax.install() in the beforeEach of my spec file.  I then receive the error Property 'Ajax' does not exist on type 'typeof jasmine'.

Any ideas?  I feel it is something simple I am missing.

Thanks,
Steve

Gregg Van Hove

unread,
Feb 28, 2018, 7:11:57 PM2/28/18
to jasmi...@googlegroups.com
That error message sounds like it might be a TypeScript typings problem, and the compiler doesn't know that there will be an Ajax object off of jasmine. It should be possible to generate some typings for jasmine-ajax and then hook them up to whatever existing typings you're using for Jasmine so the TypeScript compiler knows about everything.

Unfortunately, I haven't done too much TypeScript, so I'm not sure what all is necessary to make this all work.

Hope this helps. Thanks for using Jasmine!

-Gregg

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+unsubscribe@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at https://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages