Skip to content

[question?] Cleanup after tests (Resource.destroy) causing TypeError #155

Description

@Fishrock123

Getting this error

(Summary) Uncaught TypeError: Property 'tracks' of object { ... } is not a function

Uncaught TypeError: Property 'tracks' of object {"id":"72f17dbd-a826-4b6f-9b23-ffa71674e405","name":"user","permalink":"user","email":"user@zambah.com","following":[],"likes":[],"tracks":[],"followers":[],"password":"12345678","twitter":{},"facebook":{},"google":{},"profile_pic":"/img/default_avatar.png","cover":"/img/music.jpg","accountType":"artist","emailConfirmed":false,"track_ids":[],"resource":"User"} is not a function

At this line: https://github.com/flatiron/resourceful/blob/master/lib/resourceful/resource.js#L642

From the afterEach loop of my mocha tests here:

describe('api - profile', function () {
  var app
  var user
  var User

  function createApp(done, opts) {
    var config = opts || {}

    // UserAccount makes a User Resource
    //  providing an arg changes the `uri` of the memorystore
    User = UserAccount(randomstring.generate(25))
    app = express()

    app.use(bodyParser.json({
      limit: '100kb'
    }))

    User.create(user_create, function(err, _user) { // creates and sets `user`, etc
      user = _user

      app.use(function(req, res, next) {
        req.user = config.user || user
        next()
      })

      app.use('/api', api({ UserAccount: User }))

      if ('function' === typeof done) done()
    })
  }

  beforeEach(createApp)

  afterEach(function (done) {
    User.destroy(user.id, function () { // error caused here //
      done()
    })
  })

  // tests ...
})

(Running into this error for just one, but I really I need a way to clear all data from the associated memory store. ala #53)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions