Use 'del' to remove passing test videos (#2325)

This commit is contained in:
Jon Koops 2022-03-24 10:01:41 +01:00 committed by GitHub
parent 1d5eccfbb2
commit e46f818650
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 4 deletions

View file

@ -1,8 +1,8 @@
// The Webpack preprocessor does not include any types so it will have to be ignored. // The Webpack preprocessor does not include any types so it will have to be ignored.
// @ts-ignore // @ts-ignore
import webpackPreprocessor from "@cypress/webpack-batteries-included-preprocessor"; import webpackPreprocessor from "@cypress/webpack-batteries-included-preprocessor";
import del from "del";
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin"; import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
import fs from "fs";
import path from "path"; import path from "path";
// *********************************************************** // ***********************************************************
@ -37,7 +37,8 @@ const configurePlugins: Cypress.PluginConfig = (on) => {
webpackOptions, webpackOptions,
}) })
); );
on("after:spec", (spec, results) => {
on("after:spec", async (spec, results) => {
if (!results.video) { if (!results.video) {
return; return;
} }
@ -47,9 +48,9 @@ const configurePlugins: Cypress.PluginConfig = (on) => {
attempts.some(({ state }) => state === "failed") attempts.some(({ state }) => state === "failed")
); );
// delete the video if the spec passed and no tests retried // Delete the video if the spec passed and no tests were retried.
if (!failures) { if (!failures) {
fs.rmSync(results.video); await del(results.video);
} }
}); });
}; };

54
package-lock.json generated
View file

@ -55,6 +55,7 @@
"cypress": "^9.5.2", "cypress": "^9.5.2",
"cypress-file-upload": "^5.0.8", "cypress-file-upload": "^5.0.8",
"decompress": "^4.2.1", "decompress": "^4.2.1",
"del": "^6.0.0",
"eslint": "^8.11.0", "eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1", "eslint-plugin-cypress": "^2.12.1",
@ -8734,6 +8735,28 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/del": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/del/-/del-6.0.0.tgz",
"integrity": "sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==",
"dev": true,
"dependencies": {
"globby": "^11.0.1",
"graceful-fs": "^4.2.4",
"is-glob": "^4.0.1",
"is-path-cwd": "^2.2.0",
"is-path-inside": "^3.0.2",
"p-map": "^4.0.0",
"rimraf": "^3.0.2",
"slash": "^3.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/delayed-stream": { "node_modules/delayed-stream": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@ -12066,6 +12089,15 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/is-path-cwd": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz",
"integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==",
"dev": true,
"engines": {
"node": ">=6"
}
},
"node_modules/is-path-inside": { "node_modules/is-path-inside": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
@ -28683,6 +28715,22 @@
"isobject": "^3.0.1" "isobject": "^3.0.1"
} }
}, },
"del": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/del/-/del-6.0.0.tgz",
"integrity": "sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==",
"dev": true,
"requires": {
"globby": "^11.0.1",
"graceful-fs": "^4.2.4",
"is-glob": "^4.0.1",
"is-path-cwd": "^2.2.0",
"is-path-inside": "^3.0.2",
"p-map": "^4.0.0",
"rimraf": "^3.0.2",
"slash": "^3.0.0"
}
},
"delayed-stream": { "delayed-stream": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@ -31219,6 +31267,12 @@
"has-tostringtag": "^1.0.0" "has-tostringtag": "^1.0.0"
} }
}, },
"is-path-cwd": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz",
"integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==",
"dev": true
},
"is-path-inside": { "is-path-inside": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",

View file

@ -71,6 +71,7 @@
"cypress": "^9.5.2", "cypress": "^9.5.2",
"cypress-file-upload": "^5.0.8", "cypress-file-upload": "^5.0.8",
"decompress": "^4.2.1", "decompress": "^4.2.1",
"del": "^6.0.0",
"eslint": "^8.11.0", "eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1", "eslint-plugin-cypress": "^2.12.1",