Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. 'use strict'
  2.  
  3. const test = require('ava').test
  4. const request = require('supertest')
  5. const routeList = require('../config/testConfig').routeList
  6.  
  7. test('local env', endpointTest, require('../config/testConfig').globals.development)
  8. test('test env', endpointTest, require('../config/testConfig').globals.test)
  9.  
  10. async function endpointTest (t, myGlobal) {
  11. Object.assign(global, myGlobal)
  12. const app = require('../../app').callback()
  13.  
  14. const dataList = await Promise.all(routeList.map(async item => {
  15. const res = await request(app)[item.method](item.path)
  16.  
  17. return {
  18. status: res.status,
  19. method: item.method,
  20. path: item.path
  21. }
  22. }))
  23. console.log(dataList)
  24. t.is(dataList.every(item => item.status === 200), true)
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement