Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: seed file, process.env.NODE_ENV = 'test', reference error 'after is not defined' #160

Closed
dhf-fullstack opened this issue Mar 1, 2019 · 3 comments

Comments

@dhf-fullstack
Copy link

  • What is the expected behavior?

Expected to be able to seed the test database without errors

  • What is the actual behavior?

server/db/db.js
after('close database connection')
ReferenceError: after not defined

  • What steps reproduce the behavior?

export NODE_ENV=test
npm run seed

@glebec
Copy link
Member

glebec commented Mar 1, 2019

@dhf-fullstack Why are you directly running the seed file in test mode?

It is expected / intended that NODE_ENV will only be test when running the tests via npm test, which uses mocha to run the app. Mocha registers after as a global variable.

if (process.env.NODE_ENV === 'test') {
after('close database connection', () => db.close())
}

"test": "NODE_ENV='test' mocha \"./server/**/*.spec.js\" \"./client/**/*.spec.js\" \"./script/**/*.spec.js\" --require @babel/polyfill --require @babel/register"

@dhf-fullstack
Copy link
Author

I didn't rtfm :(

when we changed a model, I wanted to change my local -test database without running the test suite. It was not a needful thing to do.

@glebec
Copy link
Member

glebec commented Mar 3, 2019

Nevertheless, this gives me an idea to change the sniffing from environmental to capability-based.

if (global.after) {
    after(...)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants