I wanted to test the models of my Trails.js project with a mocha. I use trailpack-waterline to upload my models to ORM Waterline.
Following the tracks of the Docs , I created User.test.js :
'use strict' const assert = require('assert') describe('User Model', () => { let User before(() => { assert(global.app.models.User) User = global.app.models.User }) it('should exist', () => { assert(User) }) })
This is done without error.
But I just canβt create an instance of the model. Following the new User({...}) docs example new User({...}) , you need to create a new user object, but this code throws a User is not a constructor error. And not a single Waterline Docs example using User.create({...}) seems to work.
The listing of the user model shows that it consists of only two methods: [ 'getModelName', 'getTableName' ] .
How to instantiate a waterline model for unit testing?
javascript unit-testing mocha waterline trailsjs
Lando-l
source share