File tree 3 files changed +32
-0
lines changed
3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -84,3 +84,24 @@ Context.prototype.retries = function (n) {
84
84
this . runnable ( ) . retries ( n ) ;
85
85
return this ;
86
86
} ;
87
+
88
+ /**
89
+ * Defines a global read-only property `mochaVar` that provides access to Mocha's name and version.
90
+ * It is accessible globally within the Node.js environment or in the browser
91
+ * @example
92
+ * console.log(globalThis.mochaVar); // Outputs: { name: "mocha", version: "X.Y.Z" }
93
+ *
94
+ * @property {Object } mochaVar - The global property containing Mocha's name and version.
95
+ * @property {string } mochaVar.name - The name of the Mocha package.
96
+ * @property {string } mochaVar.version - The current version of the Mocha package.
97
+ */
98
+ var mochaPackageJson = require ( '../package.json' ) ;
99
+ var version = mochaPackageJson . version ;
100
+ var name = mochaPackageJson . name ;
101
+
102
+ Object . defineProperty ( globalThis , 'mochaVar' , {
103
+ get : ( ) => ( {
104
+ name,
105
+ version
106
+ } )
107
+ } ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ var mochaPackageJson = require ( '../../package.json' ) ;
3
+ var version = mochaPackageJson . version ;
4
+ var name = mochaPackageJson . name ;
5
+
6
+ describe ( 'Global "mocha" object' , function ( ) {
7
+ it ( 'should have the properties name and version' , function ( ) {
8
+ expect ( globalThis . mochaVar . name , 'to equal' , name ) ;
9
+ expect ( globalThis . mochaVar . version , 'to equal' , version ) ;
10
+ } ) ;
11
+ } ) ;
You can’t perform that action at this time.
0 commit comments