mercredi 27 septembre 2017

Cannot read property 'use_env_variable' of undefined

I am using http://ift.tt/1bLYyEM to learn using the database migrations. This works fine.

As a next step, I would like to be able to run tests. My test is very simple (not using anything related to Sequelize) and looks like

import request from 'supertest';
import app from '../src/app.js';

describe('GET /', () => {
  it('should render properly', async () => {
    await request(app).get('/').expect(200);
  });
});

describe('GET /404', () => {
  it('should return 404 for non-existent URLs', async () => {
    await request(app).get('/404').expect(404);
    await request(app).get('/notfound').expect(404);
  });
});

When I run this as npm test, I get error as

➜  contactz git:(master) ✗ npm test

> express-babel@1.0.0 test /Users/harit/bl/sources/webs/q2/contactz
> jest

 FAIL  test/routes.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'use_env_variable' of undefined

      at Object.<anonymous> (db/models/index.js:11:11)
      at Object.<anonymous> (src/routes.js:3:14)
      at Object.<anonymous> (src/app.js:4:15)
      at Object.<anonymous> (test/routes.test.js:2:12)
          at Generator.next (<anonymous>)
          at Promise (<anonymous>)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.702s
Ran all test suites.
npm ERR! Test failed.  See above for more details.
➜  contactz git:(master) ✗

I am new to NodeJS, Express so not sure what is going wrong here.
The code is available at http://ift.tt/2xMZC0w

Could someone please help me know what's wrong and how to fix it?

Aucun commentaire:

Enregistrer un commentaire