Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
TG199 committed Jan 31, 2025
1 parent 2319487 commit 4649a6a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/integration/fixtures/global-teardown-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

const { it } = require('../../../lib/mocha');

it('should pass', () => {});

exports.mochaTeardown = async function () {
throw new Error('Teardown problem')
}
22 changes: 22 additions & 0 deletions test/integration/global-teardown-errors.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'

const { spawnSync } = require('child_process');
const { resolve} = require('path');
const { expect } = require('chai');

describe('global teardown errors', () => {
it('should fail with non-zero exit code and report the teardown error', () => {

const testFile = resolve(__dirname, '../fixtures/global-teardown-errors.js');

const result = spawnSync(process.execPath, [
'./bin/mocha',
testFile,
'--reporter', 'spec'
], { encoding: 'utf-8' });

expect(result.status).to.equal(1);
expect(result.stdout).to.include('Global Teardown Error:');
expect(result.stdout).to.include('Teardown problem');
});
});

0 comments on commit 4649a6a

Please # to comment.