@@ -3,6 +3,7 @@ const assert = require('assert');
3
3
const common = require ( '../../common.js' ) ;
4
4
const MockServer = require ( '../../lib/mockserver.js' ) ;
5
5
const CommandGlobals = require ( '../../lib/globals/commands.js' ) ;
6
+ const Globals = require ( "../../lib/globals" ) ;
6
7
7
8
describe ( 'testRunnerChaiExpect' , function ( ) {
8
9
before ( function ( done ) {
@@ -18,7 +19,7 @@ describe('testRunnerChaiExpect', function() {
18
19
} ) ;
19
20
20
21
it ( 'testRunWithChaiExpect' , function ( ) {
21
- const testsPath = path . join ( __dirname , '../../sampletests/withchaiexpect' ) ;
22
+ const testsPath = path . join ( __dirname , '../../sampletests/withchaiexpect/sampleWithChai.js ' ) ;
22
23
const Settings = common . require ( 'settings/settings.js' ) ;
23
24
let settings = Settings . parse ( {
24
25
selenium : {
@@ -45,11 +46,44 @@ describe('testRunnerChaiExpect', function() {
45
46
assert . ok ( runner . results . lastError instanceof Error ) ;
46
47
47
48
const ex = runner . results . lastError ;
48
-
49
49
assert . ok ( ex . message . startsWith ( 'expected [ { ELEMENT: \'0\' } ] to have a length of 2 but got 1' ) ) ;
50
50
51
- assert . strictEqual ( runner . results . modules . sampleWithChai . tests , 2 ) ;
51
+ assert . strictEqual ( runner . results . modules . sampleWithChai . tests , 3 ) ;
52
52
assert . strictEqual ( runner . results . modules . sampleWithChai . failures , 1 ) ;
53
53
} ) ;
54
54
} ) ;
55
+
56
+ it ( 'test run with global expect()' , function ( ) {
57
+ const testsPath = path . join ( __dirname , '../../sampletests/withchaiexpect/sampleWithGlobalExpect.js' ) ;
58
+
59
+ const Settings = common . require ( 'settings/settings.js' ) ;
60
+ let settings = Settings . parse ( {
61
+ selenium : {
62
+ port : 10195 ,
63
+ host : 'localhost' ,
64
+ start_process : false
65
+ } ,
66
+ globals : {
67
+ test : assert ,
68
+ reporter ( ) {
69
+ }
70
+ } ,
71
+ output_folder : false ,
72
+ silent : false ,
73
+ output : false
74
+ } ) ;
75
+
76
+ const Globals = require ( '../../lib/globals.js' ) ;
77
+
78
+ return Globals . startTestRunner ( testsPath , settings )
79
+ . then ( runner => {
80
+ assert . ok ( runner . results . lastError instanceof Error ) ;
81
+
82
+ const ex = runner . results . lastError ;
83
+ assert . strictEqual ( ex . message , 'Property ".present" is not available when asserting on non-element values.' ) ;
84
+
85
+ assert . strictEqual ( runner . results . modules . sampleWithGlobalExpect . tests , 2 ) ;
86
+ assert . strictEqual ( runner . results . modules . sampleWithGlobalExpect . errors , 1 ) ;
87
+ } ) ;
88
+ } ) ;
55
89
} ) ;
0 commit comments