-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcypress.config.js
38 lines (34 loc) · 1.19 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
const { defineConfig } = require('cypress');
const zip = require('@zip.js/zip.js');
module.exports = defineConfig({
defaultCommandTimeout: 10000,
e2e: {
setupNodeEvents(on, config) {
on('task', {
async validateManifestFromZip({ drawingPackage, expectedManifest }) {
const zipFileReader = new zip.Data64URIReader(drawingPackage);
const zipReader = new zip.ZipReader(zipFileReader);
let downloadedManifest = {};
const entries = await zipReader.getEntries();
for (let i = 0; i < entries.length; i++) {
const file = entries[i];
if (file.filename.toLowerCase() === 'manifest.json') {
const data = await file.getData(new zip.BlobWriter());
downloadedManifest = JSON.parse(await data.text());
}
}
if (JSON.stringify(downloadedManifest) !== JSON.stringify(expectedManifest)) {
throw new Error(
JSON.stringify({
error: 'Manifest does not match.',
downloadedManifest,
expectedManifest,
})
);
}
return null;
},
});
},
},
});