File tree 2 files changed +43
-0
lines changed
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 37
37
"mocha" : " ^2.0.1" ,
38
38
"plur" : " ^1.0.0" ,
39
39
"resolve-from" : " ^1.0.0" ,
40
+ "temp" : " ^0.8.3" ,
40
41
"through" : " ^2.3.4"
41
42
}
42
43
}
Original file line number Diff line number Diff line change
1
+ var path = require ( 'path' ) ;
2
+ var temp = require ( 'temp' ) ;
3
+ var mocha = require ( '../' ) ;
4
+ var fs = require ( 'fs' ) ;
5
+ var assert = require ( 'assert' ) ;
6
+
7
+ var tempFile
8
+ const filePrefix = './' ;
9
+
10
+ function removeFile ( file ) {
11
+ try {
12
+ fs . unlinkSync ( file ) ;
13
+ } catch ( err ) { }
14
+ }
15
+
16
+ beforeEach ( function ( ) {
17
+ tempFile = temp . path ( { dir :process . cwd ( ) , suffix : '.js' } ) ;
18
+ tempFileBaseName = path . basename ( tempFile ) ;
19
+ fs . closeSync ( fs . openSync ( tempFile , 'w' ) ) ;
20
+ } ) ;
21
+
22
+ afterEach ( function ( ) {
23
+ removeFile ( tempFile ) ;
24
+ } ) ;
25
+
26
+
27
+ it ( 'should fail when trying to require a file that doesn\'t exist' , function ( ) {
28
+ removeFile ( tempFile ) ;
29
+ assert . throws ( function ( ) {
30
+ mocha ( { require : [ filePrefix + tempFileBaseName ] } ) ;
31
+ } ) ;
32
+ } )
33
+
34
+ it ( 'should be able to import js-files in cwd' , function ( ) {
35
+ mocha ( { require : [ filePrefix + tempFileBaseName ] } ) ;
36
+ } ) ;
37
+
38
+ it ( 'should fail when not having the ./ file prefix' , function ( ) {
39
+ assert . throws ( function ( ) {
40
+ mocha ( { require : [ tempFileBaseName ] } )
41
+ } ) ;
42
+ } ) ;
You can’t perform that action at this time.
0 commit comments