forked from Together-100Devs/Together
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.js
55 lines (54 loc) · 1.53 KB
/
cypress.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const { defineConfig } = require("cypress");
module.exports = defineConfig({
env: {
CYPRESS_NO_DELAYS: process.env.CYPRESS_NO_DELAYS,
},
e2e: {
baseUrl: "http://localhost:3000",
experimentalRunAllSpecs: true,
setupNodeEvents(on, config) {
require("@cypress/code-coverage/task")(on, config);
on("task", {
clearDatabase() {
require("dotenv").config({ path: "./server/config/.env" });
return require("./server/config/database")().then(async conn => {
for (const { name } of await conn.connection.db
.listCollections()
.toArray()) {
await conn.connection.db.collection(name).deleteMany();
}
return null;
});
},
createEvent({
title,
description,
startAt,
endAt,
location,
user,
groupId,
}) {
require("dotenv").config({ path: "./server/config/.env" });
return require("./server/config/database")().then(async () => {
const { Event } = require("./server/models/Event");
const event = await Event.create({
title,
description,
startAt,
endAt,
location,
user,
groupId,
});
return event;
});
},
generateObjectId() {
return require("mongoose").Types.ObjectId().toString();
},
});
return config;
},
},
});