Skip to content

Instantly share code, notes, and snippets.

@nadvolod
Created August 6, 2020 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadvolod/dee5c5029d3316c6bace2ad97cf88e81 to your computer and use it in GitHub Desktop.
Save nadvolod/dee5c5029d3316c6bace2ad97cf88e81 to your computer and use it in GitHub Desktop.
var assert = require('assert');
let failureCount = 0;
before(function () {
console.log('before()', failureCount)
});
beforeEach(function () {
console.log('beforeEach()', failureCount)
});
after(function () {
console.log('after()', failureCount)
});
afterEach(function () {
console.log('afterEach()', failureCount)
});
describe('Test 1', () => {
it('should fail', () => {
failureCount++
console.log('Test 1', failureCount)
assert.equal(false, true);
});
});
describe('Test 2', () => {
beforeEach(() => {
console.log('beforeEach()', failureCount)
failureCount = 0
});
it('should pass', () => {
assert.equal(false, false);
});
});
describe('Test 3', () => {
it('should equal 0', () => {
assert.equal(failureCount, 0);
});
});
SL-0369:mocha-test nikolayadvolodkin$ ./node_modules/mocha/bin/mocha
before() 0
Test 1
beforeEach() 0
Test 1 1
1) should fail
afterEach() 1
Test 2
beforeEach() 1
beforeEach() 1
✓ should pass
afterEach() 0
Test 3
beforeEach() 0
✓ should equal 0
afterEach() 0
after() 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment