1
1
require ( './hooks' ) ;
2
2
require ( './setSelection' ) ;
3
3
4
+ const wpCypress = Cypress . platform === 'win32'
5
+ ? 'node_modules\\.bin\\wp-cypress' : 'node_modules/.bin/wp-cypress' ;
6
+
4
7
const commands = {
5
8
wp ( command ) {
6
- cy . exec ( `node_modules/.bin/wp-cypress wp "${ command } "` ) ;
9
+ cy . exec ( `${ wpCypress } wp "${ command } "` ) ;
7
10
} ,
8
11
9
12
seed ( seeder ) {
10
- cy . exec ( `node_modules/.bin/wp-cypress wp "seed ${ seeder } "` ) . then ( ( result ) => {
13
+ cy . exec ( `${ wpCypress } wp "seed ${ seeder } "` ) . then ( ( result ) => {
11
14
cy . log ( result . stdout ) ;
12
15
} ) ;
13
16
} ,
14
17
15
18
seedClean ( seeder ) {
16
- cy . exec ( `node_modules/.bin/wp-cypress wp "seed ${ seeder } --clean"` ) . then (
19
+ cy . exec ( `${ wpCypress } wp "seed ${ seeder } --clean"` ) . then (
17
20
( result ) => {
18
21
cy . log ( result . stdout ) ;
19
22
} ,
@@ -22,7 +25,7 @@ const commands = {
22
25
23
26
cleanThenSeed ( seeder ) {
24
27
cy . exec (
25
- `node_modules/.bin/wp-cypress wp "seed ${ seeder } --clean-first"` ,
28
+ `${ wpCypress } wp "seed ${ seeder } --clean-first"` ,
26
29
) . then ( ( result ) => {
27
30
cy . log ( result . stdout ) ;
28
31
} ) ;
@@ -31,27 +34,27 @@ const commands = {
31
34
resetWP ( version = false ) {
32
35
const wpVersion = version || ( Cypress . wp || { } ) . version || false ;
33
36
cy . log ( 'WP Cypress: performing full teardown...' ) ;
34
- cy . exec ( `node_modules/.bin/wp-cypress soft-reset ${ wpVersion ? `--version=' ${ wpVersion } ' ` : '' } ` ) ;
37
+ cy . exec ( `${ wpCypress } soft-reset ${ wpVersion ? `--version=" ${ wpVersion } " ` : '' } ` ) ;
35
38
} ,
36
39
37
40
installTheme ( name ) {
38
- cy . exec ( `node_modules/.bin/wp-cypress wp "theme install ${ name } "` ) ;
41
+ cy . exec ( `${ wpCypress } wp "theme install ${ name } "` ) ;
39
42
} ,
40
43
41
44
activateTheme ( name ) {
42
- cy . exec ( `node_modules/.bin/wp-cypress wp "theme activate ${ name } "` ) ;
45
+ cy . exec ( `${ wpCypress } wp "theme activate ${ name } "` ) ;
43
46
} ,
44
47
45
48
installPlugin ( name ) {
46
- cy . exec ( `node_modules/.bin/wp-cypress wp "plugin install ${ name } "` ) ;
49
+ cy . exec ( `${ wpCypress } wp "plugin install ${ name } "` ) ;
47
50
} ,
48
51
49
52
activatePlugin ( name ) {
50
- cy . exec ( `node_modules/.bin/wp-cypress wp "plugin activate ${ name } "` ) ;
53
+ cy . exec ( `${ wpCypress } wp "plugin activate ${ name } "` ) ;
51
54
} ,
52
55
53
56
deactivatePlugin ( name ) {
54
- cy . exec ( `node_modules/.bin/wp-cypress wp "plugin deactivate ${ name } "` ) ;
57
+ cy . exec ( `${ wpCypress } wp "plugin deactivate ${ name } "` ) ;
55
58
} ,
56
59
57
60
visitAdmin ( options = { } ) {
@@ -68,7 +71,7 @@ const commands = {
68
71
69
72
switchUser ( user = 'admin' , password = null ) {
70
73
if ( password ) {
71
- cy . exec ( 'node_modules/.bin/wp-cypress wp "wp-cypress-set-user --logout"' ) . then ( ( ) => {
74
+ cy . exec ( ` ${ wpCypress } wp "wp-cypress-set-user --logout"` ) . then ( ( ) => {
72
75
cy . clearCookies ( ) ;
73
76
cy . visit ( '/wp-login.php?loggedout=true' ) ;
74
77
@@ -84,12 +87,12 @@ const commands = {
84
87
cy . get ( '#wp-submit' ) . click ( ) ;
85
88
} ) ;
86
89
} else {
87
- cy . exec ( `node_modules/.bin/wp-cypress wp "wp-cypress-set-user ${ user } "` ) ;
90
+ cy . exec ( `${ wpCypress } wp "wp-cypress-set-user ${ user } "` ) ;
88
91
}
89
92
} ,
90
93
91
94
logout ( ) {
92
- cy . exec ( 'node_modules/.bin/wp-cypress wp "wp-cypress-set-user --logout"' ) . then ( ( ) => {
95
+ cy . exec ( ` ${ wpCypress } wp "wp-cypress-set-user --logout"` ) . then ( ( ) => {
93
96
cy . clearCookies ( ) ;
94
97
cy . visit ( '/wp-login.php?loggedout=true' ) ;
95
98
} ) ;
0 commit comments