Skip to content

Commit

Permalink
Attempt at testing (failing due to uncaught exception)
Browse files Browse the repository at this point in the history
  • Loading branch information
prust committed Jun 12, 2019
1 parent c94fc46 commit 30c7ffb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
6 changes: 5 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ module.exports = config => {
pattern: 'test/browser-specific/fixtures/esm.fixture.mjs',
type: 'module'
},
{pattern: 'test/browser-specific/esm.spec.mjs', type: 'module'}
{pattern: 'test/browser-specific/esm.spec.mjs', type: 'module'},
{
pattern: 'test/browser-specific/uncaught-exception.spec.mjs',
type: 'module'
}
];
break;
default:
Expand Down
27 changes: 27 additions & 0 deletions test/browser-specific/uncaught-exception.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import '/base/mocha.js';

var Mocha = window.Mocha;
var Suite = Mocha.Suite;
var Runner = Mocha.Runner;

mocha.allowUncaught()

it('should include the stack of uncaught exceptions', function(done) {
var suite = new Suite('Suite', 'root');
var runner = new Runner(suite);
runner.allowUncaught = true;
var err;
runner.fail = function(e) {
err = e;
};

setTimeout(function throwTestError() {
throw new Error('test error');
}, 1);

setTimeout(function() {
expect(err, 'to be an', Error);
expect(err.stack, 'to contain', 'at throwTestError')
done();
}, 2);
});

0 comments on commit 30c7ffb

Please sign in to comment.