You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cypress/support/wp-cli.js
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,33 @@
1
+
letsnapshotCreated=false;
2
+
3
+
constcreateSnapshot=()=>{
4
+
cy.exec('wp-env run cli wp db export /tmp/clean-snapshot.sql',{
5
+
failOnNonZeroExit: false,
6
+
});
7
+
snapshotCreated=true;
8
+
};
9
+
10
+
constrestoreSnapshot=()=>{
11
+
cy.exec('wp-env run cli wp db import /tmp/clean-snapshot.sql',{
12
+
failOnNonZeroExit: false,
13
+
});
14
+
cy.exec('wp-env run cli wp cache flush',{
15
+
failOnNonZeroExit: false,
16
+
});
17
+
};
18
+
1
19
exportconstresetDatabase=()=>{
20
+
if(snapshotCreated){
21
+
restoreSnapshot();
22
+
return;
23
+
}
2
24
cy.exec('wp-env clean all',{
3
25
failOnNonZeroExit: false,
4
26
});
5
27
cy.exec(
6
28
'wp-env run cli wp user meta add 1 wp_persisted_preferences \'{"core/edit-post":{"welcomeGuide":false,"core/edit-post/pattern-modal":false,"pattern-modal":false,"edit-post/pattern-modal":false,"patternModal":false},"core":{"enableChoosePatternModal":false},"_modified":"2025-03-23T02:16:33.561Z"}\' --format=json',
7
29
);
30
+
createSnapshot();
8
31
};
9
32
exportconstinstallPlugin=(slug)=>
10
33
cy.exec(`wp-env run cli wp plugin install ${slug} --activate`,{
0 commit comments