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

ReferenceError: $ is not defined #963

Closed
LiTiang opened this issue Jul 14, 2016 · 3 comments
Closed

ReferenceError: $ is not defined #963

LiTiang opened this issue Jul 14, 2016 · 3 comments

Comments

@LiTiang
Copy link

LiTiang commented Jul 14, 2016

How can i use AVA with jQuery ?

In my case,
i want to test a function which is in a file called app.ts (typescript file)

and i use $.ajax (jQuery API) in that function,

so AVA will want to ask me : what is the $ meaning ?????

Note that, i want to keep unit test simple, clear,

i use jQuery, but it is not meaning i also want to test DOM

NOW i just want to let jQuery work in AVA

How can do that ?

@jamestalmage
Copy link
Contributor

We don't have direct browser support yet.

There is a recipe for mocking the DOM here. Some preliminary work on a browser solution via karma (#942), and work on a full standalone browser test runner (#887).

@LiTiang
Copy link
Author

LiTiang commented Jul 14, 2016

How to access window in test file ?

Hi, @jamestalmage , thanks reply

I read article for mocking the DOM which u present

but i have no idea how can i access window object in my AVA test file ?

In Node, jQuery need window to initalize

like this var $ = jQuery = require('jquery')(window);

AVA must know $,
because it really execute that code,
that meaning, i must declare $ in test file,
then run all test

@LiTiang
Copy link
Author

LiTiang commented Jul 15, 2016

ok, i solve it,
i decide to use javascript instead of typescript,
it seems there is no need to use typescript in AVA now,
because i find the way to load typescript module directly in javascript

anyway, @jamestalmage thanks again

@LiTiang LiTiang closed this as completed Jul 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants