still troubleshooting auth issue in testing
This commit is contained in:
@@ -1,27 +1,30 @@
|
|||||||
import supertest from 'supertest'
|
import superagent from 'superagent';
|
||||||
import loginUser from '../../helpers/loginUser';
|
import request from 'supertest';
|
||||||
import { IRecipe } from '../../../schemas'
|
|
||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import app from '../../..';
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const APISTRING = process.env.APISTRING || 'localhost:8080';
|
const APISTRING = process.env.APISTRING || 'localhost:8080';
|
||||||
const server = supertest.agent(app);
|
|
||||||
|
|
||||||
describe('/recipe', () => {
|
describe('/recipe', () => {
|
||||||
beforeAll(() => {
|
const server = superagent.agent();
|
||||||
server.post('/auth/login')
|
|
||||||
.send({ email: 'verifieduser@test.com', password: 'coolpassword' });
|
beforeAll((done) => {
|
||||||
|
request(APISTRING).post('/auth/login')
|
||||||
|
.send({ email: 'verifieduser@test.com', password: 'coolpassword' })
|
||||||
|
.end((err, res) => {
|
||||||
|
if (err) throw err;
|
||||||
|
server.jar.setCookie(res.body.cookie);
|
||||||
|
return done();
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('GET /', () => {
|
describe('GET /', () => {
|
||||||
it('gets an array of recipes', () => {
|
it('gets an array of recipes', () => {
|
||||||
server.get('/recipe').end((err, res) => {
|
request(APISTRING).get('/recipe')
|
||||||
if (err) throw err;
|
.withCredentials(true)
|
||||||
console.log(res.body);
|
.end((err, res) => {
|
||||||
expect(res.statusCode).toBe(200);
|
expect(res.statusCode).toBe(200);
|
||||||
expect(res.body.ok).toBeTruthy();
|
expect(res.body).toBeDefined();
|
||||||
});
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user