1

I am using following gulp task to execute the karma/jasmine unit test cases . however i was not able access the karma.conf.js file for some reason. this problem occurs when i use this pathpackage to access the karma.conf.js file.

gulp task

gulp.task('tdd', function (done) {
      karma.start({
        configFile: fs.readFile(path.join(__dirname, '../Tests/karma.conf.js')),
        singleRun: true
      }, done);
    });

error i am getting

PS C:\Users\dell pc\Documents\Work\WebApiRole> gulp tdd
[13:47:58] Using gulpfile ~\Documents\Work\WebApiRole\Gulpfile.js
[13:47:58] Starting 'tdd'...
INFO [karma]: Karma v0.12.32 server started at http://localhost:9876/

It just wait forever in above state .

But when just access the file like this configFile: __dirname, '../Tests/karma.conf.js' (without fs.readFile(path.join) then the gulp access the karma.conf.js file successfully .

can someone give me an idea regarding what i am doing wrong here ?

Malik
  • 3,520
  • 7
  • 29
  • 42

1 Answers1

2

configFile property is just a file name. So when you provide __dirname + '../Tests/karma.conf.js' it corresponds to the actual file location. You can actually do:

configFile: path.join(__dirname, '../Tests/karma.conf.js')

With fs.readFile you read a file and provide its contents to the karma runner. I am not sure why you are not getting any error.

zaynetro
  • 2,298
  • 20
  • 28
  • Thank you . this issue bugged me for several hours . I was under the impression that fs.readFile access the file . – Malik Jun 17 '15 at 08:46
  • Thank you so much @zaynetro This fixed a headache! Karma really needs to document a tutorial for different scenarios. – Ankit Tanna Nov 15 '16 at 22:33