Issue tracker : put and delete keep failing


This is a story with a few twists. It started like below

I 'm failing this put test and the delete test

You can send a PUT request to /api/issues/{projectname} with an _id and one or more fields to update. On success, the updated_on field should be updated, and returned should be { result: 'successfully updated', '_id': _id }

In my console I get two error messages that I do not understand :

Error: expected { Object (id, assigned_to…) } to be an array
Error: expected { status: ‘unavailable’ } to be an array

I looked through all the posts on the forum and I discoverd the problem could lie in my get route. I had a findOne for requests with an id and find() for other requests in there. I got rid of the findOne and fixed the code in the rest of the function. PUT worked smoothly, delete still didn’t.

So I thought, I can’t sleep, let’s work on it a little more.

But then both tests started failing again. And I’m getting CORS not origin allowed messages again. I found some code in the chai-mocha replit and copied it into the issue tracker. Put passes again, delete still doesn’t.

let error;
app.get('/_api/get-tests', cors(), function (req, res, next) {
  if (error)
    return res.json({ status: 'unavailable' });
  function (req, res, next) {
    if (! return next();
    res.json(testFilter(, req.query.type, req.query.n));
  function (req, res) {
    runner.on('done', function (report) {
      process.nextTick(() => res.json(testFilter(, req.query.type, req.query.n)));

Now I’m getting
Error: expected { status: ‘unavailable’ } to be an array
CORS-header ‘Access-Control-Allow-Origin’ is missing

Christ, I’m tired. I need to sleep.

Here’s a link to my replit :

Thanks and greets,

There were two problems:
I was using findOne() and find() in the get request, deleted findOne() and adapted the rest of the code (ObjetId!) so that tests are always getting an array
In the get the response can be undefined. So I added that as an option in the conditions and I passed the deletion tests

BTW these posts helped me a lot:

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