11import assert from 'assert' ;
2- import { expect } from 'expect ' ;
3- import path from 'path' ;
2+ import { expect } from 'chai ' ;
3+ import path , { dirname } from 'path' ;
44import { exec } from 'child_process' ;
5+ import { fileURLToPath } from 'url' ;
56
6- const __dirname = path . resolve ( '.' ) ;
7- const runner = path . join ( __dirname , 'bin/codecept.js' ) ;
8- const codecept_dir = path . join ( __dirname , 'test/data/sandbox' ) ;
7+ const __dirname = dirname ( fileURLToPath ( import . meta . url ) ) ;
8+ const runner = path . join ( __dirname , '../../ bin/codecept.js' ) ;
9+ const codecept_dir = path . join ( __dirname , '../../ test/data/sandbox' ) ;
910const codecept_run = `${ runner } run-multiple --config ${ codecept_dir } /codecept.multiple.js ` ;
1011
1112describe ( 'CodeceptJS Multiple Runner' , function ( ) {
1213 this . timeout ( 40000 ) ;
1314
1415 before ( ( ) => {
15- global . codecept_dir = path . join ( __dirname , '/../data/sandbox' ) ;
16+ global . codecept_dir = codecept_dir ;
17+ process . chdir ( codecept_dir ) ;
1618 } ) ;
1719
1820 it ( 'should execute one suite with browser' , ( done ) => {
1921 exec ( `${ codecept_run } default:firefox` , ( err , stdout ) => {
22+ console . log ( stdout )
2023 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
21- expect ( stdout ) . to . include ( '.default:firefox] print browser ' ) ;
22- expect ( stdout ) . to . not . include ( '.default:chrome] print browser ' ) ;
24+ expect ( stdout ) . to . include ( '.default:firefox]' ) ;
25+ expect ( stdout ) . to . not . include ( '.default:chrome]' ) ;
2326 assert ( ! err ) ;
2427 done ( ) ;
2528 } ) ;
@@ -28,17 +31,17 @@ describe('CodeceptJS Multiple Runner', function () {
2831 it ( 'should execute all suites' , ( done ) => {
2932 exec ( `${ codecept_run } --all` , ( err , stdout ) => {
3033 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
31- expect ( stdout ) . to . include ( '[1.default:chrome] print browser ' ) ;
32- expect ( stdout ) . to . include ( '[2.default:firefox] print browser ' ) ;
33- expect ( stdout ) . to . include ( '[3.mobile:android] print browser ' ) ;
34- expect ( stdout ) . to . include ( '[4.mobile:safari] print browser ' ) ;
35- expect ( stdout ) . to . include ( '[5.mobile:chrome] print browser ' ) ;
36- expect ( stdout ) . to . include ( '[6.mobile:safari] print browser ' ) ;
37- expect ( stdout ) . to . include ( '[7.grep:chrome] @grep print browser size ' ) ;
38- expect ( stdout ) . to . include ( '[8.grep:firefox] @grep print browser size ' ) ;
39- expect ( stdout ) . to . not . include ( '[7.grep:chrome] print browser ' ) ;
40- expect ( stdout ) . to . include ( '[1.default:chrome] @grep print browser size ' ) ;
41- expect ( stdout ) . to . include ( '[3.mobile:android] @grep print browser size ' ) ;
34+ expect ( stdout ) . to . include ( '[1.default:chrome]' ) ;
35+ expect ( stdout ) . to . include ( '[2.default:firefox]' ) ;
36+ expect ( stdout ) . to . include ( '[3.mobile:android]' ) ;
37+ expect ( stdout ) . to . include ( '[4.mobile:safari]' ) ;
38+ expect ( stdout ) . to . include ( '[5.mobile:chrome]' ) ;
39+ expect ( stdout ) . to . include ( '[6.mobile:safari]' ) ;
40+ expect ( stdout ) . to . include ( '[7.grep:chrome]' ) ;
41+ expect ( stdout ) . to . include ( '[8.grep:firefox]' ) ;
42+ expect ( stdout ) . to . include ( '[7.grep:chrome]' ) ;
43+ expect ( stdout ) . to . include ( '[1.default:chrome]' ) ;
44+ expect ( stdout ) . to . include ( '[3.mobile:android]' ) ;
4245 assert ( ! err ) ;
4346 done ( ) ;
4447 } ) ;
@@ -47,8 +50,8 @@ describe('CodeceptJS Multiple Runner', function () {
4750 it ( 'should replace parameters' , ( done ) => {
4851 exec ( `${ codecept_run } grep --debug` , ( err , stdout ) => {
4952 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
50- expect ( stdout ) . to . include ( '[1.grep:chrome] › maximize ' ) ;
51- expect ( stdout ) . to . include ( '[2.grep:firefox] › 1200x840 ' ) ;
53+ expect ( stdout ) . to . include ( '[1.grep:chrome]' ) ;
54+ expect ( stdout ) . to . include ( '[2.grep:firefox]' ) ;
5255 assert ( ! err ) ;
5356 done ( ) ;
5457 } ) ;
@@ -57,12 +60,12 @@ describe('CodeceptJS Multiple Runner', function () {
5760 it ( 'should execute multiple suites' , ( done ) => {
5861 exec ( `${ codecept_run } mobile default ` , ( err , stdout ) => {
5962 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
60- expect ( stdout ) . to . include ( '[1.mobile:android] print browser ' ) ;
61- expect ( stdout ) . to . include ( '[2.mobile:safari] print browser ' ) ;
62- expect ( stdout ) . to . include ( '[3.mobile:chrome] print browser ' ) ;
63- expect ( stdout ) . to . include ( '[4.mobile:safari] print browser ' ) ;
64- expect ( stdout ) . to . include ( '[5.default:chrome] print browser ' ) ;
65- expect ( stdout ) . to . include ( '[6.default:firefox] print browser ' ) ;
63+ expect ( stdout ) . to . include ( '[1.mobile:android]' ) ;
64+ expect ( stdout ) . to . include ( '[2.mobile:safari]' ) ;
65+ expect ( stdout ) . to . include ( '[3.mobile:chrome]' ) ;
66+ expect ( stdout ) . to . include ( '[4.mobile:safari]' ) ;
67+ expect ( stdout ) . to . include ( '[5.default:chrome]' ) ;
68+ expect ( stdout ) . to . include ( '[6.default:firefox]' ) ;
6669 assert ( ! err ) ;
6770 done ( ) ;
6871 } ) ;
@@ -71,9 +74,9 @@ describe('CodeceptJS Multiple Runner', function () {
7174 it ( 'should execute multiple suites with selected browsers' , ( done ) => {
7275 exec ( `${ codecept_run } mobile:safari default:chrome ` , ( err , stdout ) => {
7376 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
74- expect ( stdout ) . to . include ( '[1.mobile:safari] print browser ' ) ;
75- expect ( stdout ) . to . include ( '[2.mobile:safari] print browser ' ) ;
76- expect ( stdout ) . to . include ( '[3.default:chrome] print browser ' ) ;
77+ expect ( stdout ) . to . include ( '[1.mobile:safari]' ) ;
78+ expect ( stdout ) . to . include ( '[2.mobile:safari]' ) ;
79+ expect ( stdout ) . to . include ( '[3.default:chrome]' ) ;
7780 assert ( ! err ) ;
7881 done ( ) ;
7982 } ) ;
@@ -82,10 +85,10 @@ describe('CodeceptJS Multiple Runner', function () {
8285 it ( 'should print steps' , ( done ) => {
8386 exec ( `${ codecept_run } default --steps` , ( err , stdout ) => {
8487 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
85- expect ( stdout ) . to . include ( '[2.default:firefox] print browser ' ) ;
86- expect ( stdout ) . to . include ( '[2.default:firefox] I print browser ' ) ;
87- expect ( stdout ) . to . include ( '[1.default:chrome] print browser ' ) ;
88- expect ( stdout ) . to . include ( '[1.default:chrome] I print browser ' ) ;
88+ expect ( stdout ) . to . include ( '[2.default:firefox] ' ) ;
89+ expect ( stdout ) . to . include ( '[2.default:firefox] I' ) ;
90+ expect ( stdout ) . to . include ( '[1.default:chrome] ' ) ;
91+ expect ( stdout ) . to . include ( '[1.default:chrome] I' ) ;
8992 assert ( ! err ) ;
9093 done ( ) ;
9194 } ) ;
@@ -94,10 +97,10 @@ describe('CodeceptJS Multiple Runner', function () {
9497 it ( 'should pass grep to configuration' , ( done ) => {
9598 exec ( `${ codecept_run } default --grep @grep` , ( err , stdout ) => {
9699 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
97- expect ( stdout ) . to . include ( '[1.default:chrome] @grep print browser size ' ) ;
98- expect ( stdout ) . to . include ( '[2.default:firefox] @grep print browser size ' ) ;
99- expect ( stdout ) . to . not . include ( '[1.default:chrome] print browser ' ) ;
100- expect ( stdout ) . to . not . include ( '[2.default:firefox] print browser ' ) ;
100+ expect ( stdout ) . to . include ( '[1.default:chrome]' ) ;
101+ expect ( stdout ) . to . include ( '[2.default:firefox]' ) ;
102+ expect ( stdout ) . to . not . include ( '[1.default:chrome]' ) ;
103+ expect ( stdout ) . to . not . include ( '[2.default:firefox]' ) ;
101104 assert ( ! err ) ;
102105 done ( ) ;
103106 } ) ;
@@ -106,10 +109,10 @@ describe('CodeceptJS Multiple Runner', function () {
106109 it ( 'should pass grep invert to configuration' , ( done ) => {
107110 exec ( `${ codecept_run } default --grep @grep --invert` , ( err , stdout ) => {
108111 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
109- expect ( stdout ) . to . not . include ( '[1.default:chrome] @grep print browser size ' ) ;
110- expect ( stdout ) . to . not . include ( '[2.default:firefox] @grep print browser size ' ) ;
111- expect ( stdout ) . to . include ( '[1.default:chrome] print browser ' ) ;
112- expect ( stdout ) . to . include ( '[2.default:firefox] print browser ' ) ;
112+ expect ( stdout ) . to . not . include ( '[1.default:chrome]' ) ;
113+ expect ( stdout ) . to . not . include ( '[2.default:firefox]' ) ;
114+ expect ( stdout ) . to . include ( '[1.default:chrome]' ) ;
115+ expect ( stdout ) . to . include ( '[2.default:firefox]' ) ;
113116 assert ( ! err ) ;
114117 done ( ) ;
115118 } ) ;
@@ -118,10 +121,10 @@ describe('CodeceptJS Multiple Runner', function () {
118121 it ( 'should pass tests to configuration' , ( done ) => {
119122 exec ( `${ codecept_run } test` , ( err , stdout ) => {
120123 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
121- expect ( stdout ) . to . include ( '[1.test:chrome] print browser size' ) ;
122- expect ( stdout ) . to . include ( '[2.test:firefox] print browser size' ) ;
123- expect ( stdout ) . to . include ( '[1.test:chrome] print browser ' ) ;
124- expect ( stdout ) . to . include ( '[2.test:firefox] print browser ' ) ;
124+ expect ( stdout ) . to . include ( '[1.test:chrome]size' ) ;
125+ expect ( stdout ) . to . include ( '[2.test:firefox]size' ) ;
126+ expect ( stdout ) . to . include ( '[1.test:chrome]' ) ;
127+ expect ( stdout ) . to . include ( '[2.test:firefox]' ) ;
125128 assert ( ! err ) ;
126129 done ( ) ;
127130 } ) ;
@@ -131,7 +134,7 @@ describe('CodeceptJS Multiple Runner', function () {
131134 exec ( `${ codecept_run } chunks` , ( err , stdout ) => {
132135 expect ( stdout ) . to . include ( 'CodeceptJS' ) ; // feature
133136 expect ( stdout ) . to . include ( '[1.chunks:chunk1:dummy] print browser' ) ;
134- expect ( stdout ) . to . include ( '[2.chunks:chunk2:dummy] @grep print browser size ' ) ;
137+ expect ( stdout ) . to . include ( '[2.chunks:chunk2:dummy]' ) ;
135138 assert ( ! err ) ;
136139 done ( ) ;
137140 } ) ;
@@ -228,7 +231,7 @@ describe('CodeceptJS Multiple Runner', function () {
228231 exec ( `${ runner } ${ _codecept_run } /codecept.require.multiple.single.json default` , ( err , stdout ) => {
229232 expect ( stdout ) . to . include ( moduleOutput ) ;
230233 expect ( stdout ) . to . not . include ( moduleOutput2 ) ;
231- ( stdout . match ( new RegExp ( moduleOutput , 'g' ) ) || [ ] ) . should . have . lengthOf ( 2 ) ;
234+ expect ( stdout . match ( new RegExp ( moduleOutput , 'g' ) ) || [ ] ) . to . have . lengthOf ( 2 ) ;
232235 assert ( ! err ) ;
233236 done ( ) ;
234237 } ) ;
@@ -239,8 +242,8 @@ describe('CodeceptJS Multiple Runner', function () {
239242 exec ( `${ runner } ${ _codecept_run } /codecept.require.multiple.several.js default` , ( err , stdout ) => {
240243 expect ( stdout ) . to . include ( moduleOutput ) ;
241244 expect ( stdout ) . to . include ( moduleOutput2 ) ;
242- ( stdout . match ( new RegExp ( moduleOutput , 'g' ) ) || [ ] ) . should . have . lengthOf ( 2 ) ;
243- ( stdout . match ( new RegExp ( moduleOutput2 , 'g' ) ) || [ ] ) . should . have . lengthOf ( 2 ) ;
245+ expect ( stdout . match ( new RegExp ( moduleOutput , 'g' ) ) || [ ] ) . to . have . lengthOf ( 2 ) ;
246+ expect ( stdout . match ( new RegExp ( moduleOutput2 , 'g' ) ) || [ ] ) . to . have . have . lengthOf ( 2 ) ;
244247 assert ( ! err ) ;
245248 done ( ) ;
246249 } ) ;
0 commit comments