Skip to content

Commit b0fc131

Browse files
committed
Delete all Safari data before launching
1 parent a198405 commit b0fc131

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
"undici": "6.19.7",
159159
"watch": "1.0.2",
160160
"webpack": "5.76.0",
161+
"rimraf": "6.0.1",
161162
"yargs": "17.7.2"
162163
}
163164
}

scripts/ci-test/karmaSafariLauncher.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
const fs = require('fs');
2020
const os = require('os');
2121
const path = require('path');
22+
const rimraf = require("rimraf");
2223

2324
var SafariBrowser = function (baseBrowserDecorator) {
2425
baseBrowserDecorator(this);
@@ -33,9 +34,27 @@ var SafariBrowser = function (baseBrowserDecorator) {
3334
);
3435
const HTML_TRAMPOLINE_PATH = path.join(SAFARI_DATA_DIR, 'redirect.html');
3536

37+
function clearSafariData() {
38+
const directoriesToClear = [
39+
path.join(SAFARI_DATA_DIR, 'Library/Caches'),
40+
path.join(SAFARI_DATA_DIR, 'Library/Cookies'),
41+
path.join(SAFARI_DATA_DIR, 'Library/Safari'),
42+
path.join(SAFARI_DATA_DIR, 'Library/WebKit'),
43+
]
44+
45+
directoriesToClear.forEach((dir) => {
46+
if (fs.existsSync(dir)) {
47+
rimraf.sync(dir);
48+
}
49+
})
50+
}
51+
3652
this._start = function (url) {
3753
var self = this;
3854

55+
// Clear cookies and other persisted data before starting the browser
56+
clearSafariData();
57+
3958
// HTML trampoline to redirect Safari to the URL where the tests are hosted.
4059
// This is necessary because Safari assumes the location we pass as an argument is a path
4160
// in the Safari Data directory. So, if we were to pass 'http://localhost:3000' as an argument,

0 commit comments

Comments
 (0)