Spaces:
Paused
Paused
Download __tests__/api/apiIntegration.test.js from imkrish/campverse-backend: direct link, hf CLI and curl.
- Browser
- Download file 830 Bytes
-
https://huggingface.co/spaces/imkrish/campverse-backend/resolve/main/__tests__/api/apiIntegration.test.js
- Command line
-
hf download hf://spaces/imkrish/campverse-backend/__tests__/api/apiIntegration.test.js
-
curl -L -o apiIntegration.test.js https://huggingface.co/spaces/imkrish/campverse-backend/resolve/main/__tests__/api/apiIntegration.test.js
830 Bytes
| /* eslint-disable no-unused-vars */ | |
| const request = require('supertest'); | |
| const { MongoMemoryServer } = require('mongodb-memory-server'); | |
| const mongoose = require('mongoose'); | |
| let app; | |
| let mongoServer; | |
| describe('API Integration Tests', () => { | |
| beforeAll(async () => { | |
| mongoServer = await MongoMemoryServer.create(); | |
| const mongoUri = mongoServer.getUri(); | |
| process.env.MONGO_URI = mongoUri; | |
| app = require('../../app'); | |
| }); | |
| afterAll(async () => { | |
| await mongoose.disconnect(); | |
| await mongoServer.stop(); | |
| }); | |
| beforeEach(async () => { | |
| try { | |
| const collections = mongoose.connection.collections; | |
| for (const key in collections) { | |
| await collections[key].deleteMany({}); | |
| } | |
| } catch (error) { | |
| console.log('Cleanup error (ignored):', error.message); | |
| } | |
| }); | |
| }); | |