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

Move some test setup/teardown to a central location. #111

Open
collin opened this issue Jun 19, 2018 · 1 comment
Open

Move some test setup/teardown to a central location. #111

collin opened this issue Jun 19, 2018 · 1 comment

Comments

@collin
Copy link
Contributor

collin commented Jun 19, 2018

I've had a number of groups who end up with quite a bit more test set-up and tear down needs.

To these students I have recommended they add a central ./test-setup.jsand instruct mocha to load this file explicitly and first.

Things that move into this file are setting up globally used mock adapters, the enzyme adapter, and database setup/teardown tasks.

"NODE_ENV='test' mocha ./test-setup \"./server/**/*.spec.js\" \"./client/**/*.spec.js\" \"./script/**/*.spec.js\" --require @babel/polyfill --require @babel/register
// test-setup.js
// with these and other hooks at the top-level.
before(() => db.sync({ force: true });
afterEach(() => db.sync({ force: true });
@glebec
Copy link
Member

glebec commented Jul 21, 2018

Sounds reasonable to me.

EDIT: though running database syncs before every test, even frontend / utility / other tests, feels a bit heavy-handed for me.

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