Issue tracker use jquery inside functional-tests.js

Hi,

I’ve started on the functional tests for the issue tracker and found some code on the forum. It shows your own ‘PUT’ test. ( Issue Tracker – PUT request ) In that test, I saw that you that .ajax is used to make a get request. That looks like fun so I tried it myself but the test doesn't recognize .ajax.

     Uncaught TypeError: $.ajax is not a function
      at Context.<anonymous> (tests/2_functional-tests.js:32:38)
      at processImmediate (internal/timers.js:461:21)

I tried copying the jquery script from index.html but the test doesn’t recognize ‘<’.

SyntaxError: Unexpected token '<'
    at compileFunction (<anonymous>)

Then I tried requiring jquery and chai-jquery (found that on the internet) but that doesn’t work either and produces the same error. (And wouldn’t know how to use what I’ve required except for = require('jquery') or = require(‘chai-jquery’)

     Uncaught TypeError: $.ajax is not a function
      at Context.<anonymous> (tests/2_functional-tests.js:32:38)
      at processImmediate (internal/timers.js:461:21)

In the docs I’m told to add script tags, the same on npm.

Is there a way to do this (that is not too complicated) ? What I know I learned here or on introductory courses.

Thanks and greets,
Karin

Hello!

Yeah, but that is used on the front end (on freecodecamp.org) to request the data from your project, not on the actual issue tracker project.

For the functional tests you don’t need to use the front end code (HTML, CSS) because you send the requests directly to your project’s API.

That said, if you ever need to parse and manipulate code on the back end (node), you can use something like cheerio.

Thanks, it clarifies something completely new to me. And thanks for the cheerio link, it may prove to be very useful one day.

Greets,
Karin

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.