-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.ts
59 lines (58 loc) · 1.75 KB
/
cypress.config.ts
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
56
57
58
59
import { defineConfig } from "cypress";
import { S3Client } from "@aws-sdk/client-s3";
import { PutObjectCommand } from "@aws-sdk/client-s3";
import fs from "fs";
export default defineConfig({
component: {
viewportHeight: 800,
viewportWidth: 1600,
devServer: {
framework: "vue",
bundler: "vite",
},
specPattern: "cypress/component/**/*.{js,jsx,ts,tsx}",
},
video: true,
videosFolder: "cypress/videos",
viewportHeight: 1080,
viewportWidth: 1920,
e2e: {
setupNodeEvents(on, config) {
on("after:spec", () => {
const videosFolder = config.videosFolder;
let AllFiles: Array<any> = [];
fs.readdir(videosFolder, (err, files) => {
if (err) {
console.log(err);
} else {
AllFiles = files.map((file) => ({
name: file,
data: fs.readFileSync(`${videosFolder}/${file}`),
}));
AllFiles.forEach((videoFileName) => {
const credentials = {
accessKeyId: config.env.S3_ACCESS_KEY,
secretAccessKey:
config.env.S3_SECRET_KEY,
};
const s3Client = new S3Client({
endpoint: config.env.S3_ENDPOINT_URL,
credentials: credentials,
region: "asia",
});
return s3Client.send(
new PutObjectCommand({
Bucket: config.env.S3_BUCKET_NAME,
Key: "cypress/" + videoFileName.name,
Body: videoFileName.data,
ContentType: "video/mp4",
})
);
});
}
});
});
},
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}'
}
})