Monday, 13 March 2017

Access var from global BeforeEach in testcase in mocha

I need a help here. I am stuck, not sure on way forward.

I am using mocha to write tests. I have global beforeEach(). I have variable declared. Is there a way to use this in testcase?? Here is an example

globalhook.js

describe('hooks', function() {
before();
console.log('reached before method');

beforeEach()
console.log('Reached beforeEach method');
var logger = 'test';



// teardown
afterEach();
console.log('reached afterEach method');

after();
console.log('reached after method');

});

My tests are in ./test folder

describe('Array2', function() {
  describe('#indexOf2()', function() {
it('should return -1 when the value is not present', function(done) {
  assert.equal(-1, [1,2,3].indexOf(4));
  done();
 });
});
});

How can i get logger in my test case?? any suggestions would be appreciated



via Rajesh

No comments:

Post a Comment