Jelajahi Sumber

Add express variable and check if app is already running in tests rather than waiting for the non-existent event

sbkwgh 8 tahun lalu
induk
melakukan
e61f80a449
4 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 1 0
      server.js
  2. 2 0
      test/admin_token.js
  3. 2 0
      test/category.js
  4. 2 0
      test/user.js

+ 1 - 0
server.js

@@ -37,6 +37,7 @@ sequelize
 		app.listen(config.port, () => {
 			console.log('Listening on ' + config.port)
 
+			app.locals.appStarted = true
 			app.emit('appStarted')
 		})
 	})

+ 2 - 0
test/admin_token.js

@@ -14,6 +14,8 @@ chai.use(require('chai-things'))
 describe('AdminToken', () => {
 	//Wait for app to start before commencing
 	before((done) => {
+		if(server.locals.appStarted) done()
+			
 		server.on('appStarted', () => {
 			done()
 		})

+ 2 - 0
test/category.js

@@ -14,6 +14,8 @@ chai.use(require('chai-things'))
 describe('Category', () => {
 	//Wait for app to start before commencing
 	before((done) => {
+		if(server.locals.appStarted) done()
+
 		server.on('appStarted', () => {
 			done()
 		})

+ 2 - 0
test/user.js

@@ -14,6 +14,8 @@ chai.use(require('chai-things'))
 describe('User', () => {
 	//Wait for app to start before commencing
 	before((done) => {
+		if(server.locals.appStarted) done()
+			
 		server.on('appStarted', () => {
 			done()
 		})