Skip to content

Commit

Permalink
existing tests: adaptions
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jan 23, 2019
1 parent 3ca5305 commit 353ae11
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('suite2', function () {
before('before suite2', function () {});
beforeEach('beforeEach suite2', function () {});
it('test suite2', function () {
runOrder.push('test suite2 - should not run');
console.log('test suite2 - should not run');
});
afterEach('afterEach suite2', function () {});
after('after suite2', function () {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('suite2', function () {
before('before suite2', function () {});
beforeEach('beforeEach suite2', function () {});
it('test suite2', function () {
runOrder.push('test suite2 - should not run');
console.log('test suite2 - should not run');
});
afterEach('afterEach suite2', function () {});
after('after suite2', function () {});
Expand Down
5 changes: 4 additions & 1 deletion test/integration/hook-err.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ describe('hook error handling', function() {
describe('before hook error tip', function() {
before(run('hooks/before-hook-error-tip.fixture.js', onlyErrorTitle()));
it('should verify results', function() {
expect(lines, 'to equal', ['1) spec 2', '"before all" hook:']);
expect(lines, 'to equal', [
'1) spec 2',
'"before all" hook for "skipped":'
]);
});
});

Expand Down
10 changes: 8 additions & 2 deletions test/integration/multiple-done.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ describe('multiple calls to done()', function() {
});

it('correctly attributes the error', function() {
assert.strictEqual(res.failures[0].fullTitle, 'suite "before all" hook');
assert.strictEqual(
res.failures[0].fullTitle,
'suite "before all" hook in "suite"'
);
assert.strictEqual(
res.failures[0].err.message,
'done() called multiple times'
Expand All @@ -116,7 +119,10 @@ describe('multiple calls to done()', function() {
it('correctly attributes the errors', function() {
assert.strictEqual(res.failures.length, 2);
res.failures.forEach(function(failure) {
assert.strictEqual(failure.fullTitle, 'suite "before each" hook');
assert.strictEqual(
failure.fullTitle,
'suite "before each" hook in "suite"'
);
assert.strictEqual(failure.err.message, 'done() called multiple times');
});
});
Expand Down
10 changes: 8 additions & 2 deletions test/integration/options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ describe('options', function() {
}
expect(res, 'to have failed')
.and('to have failed test count', 1)
.and('to have failed test', '"before all" hook: before suite1')
.and(
'to have failed test',
'"before all" hook: before suite1 for "test suite1"'
)
.and('to have passed test count', 0);
done();
});
Expand Down Expand Up @@ -147,7 +150,10 @@ describe('options', function() {
}
expect(res, 'to have failed')
.and('to have failed test count', 1)
.and('to have failed test', '"after all" hook: after suite1A')
.and(
'to have failed test',
'"after all" hook: after suite1A for "test suite1A"'
)
.and('to have passed test count', 2)
.and('to have passed test order', 'test suite1', 'test suite1A');
done();
Expand Down
12 changes: 10 additions & 2 deletions test/unit/runner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,13 @@ describe('Runner', function() {
describe('.failHook(hook, err)', function() {
it('should increment .failures', function() {
expect(runner.failures, 'to be', 0);
runner.failHook(new Test('fail hook 1', noop), {});
var test1 = new Test('fail hook 1', noop);
var test2 = new Test('fail hook 2', noop);
suite.addTest(test1);
suite.addTest(test2);
runner.failHook(test1, {});
expect(runner.failures, 'to be', 1);
runner.failHook(new Test('fail hook 2', noop), {});
runner.failHook(test2, {});
expect(runner.failures, 'to be', 2);
});

Expand All @@ -364,6 +368,7 @@ describe('Runner', function() {

it('should emit "fail"', function(done) {
var hook = new Hook();
hook.parent = suite;
var err = {};
runner.on('fail', function(hook, err) {
expect(hook, 'to be', hook);
Expand All @@ -375,6 +380,7 @@ describe('Runner', function() {

it('should not emit "end" if suite bail is not true', function(done) {
var hook = new Hook();
hook.parent = suite;
var err = {};
suite.bail(false);
runner.on('end', function() {
Expand Down Expand Up @@ -454,6 +460,7 @@ describe('Runner', function() {

it('should prettify the stack-trace', function(done) {
var hook = new Hook();
hook.parent = suite;
var err = new Error();
// Fake stack-trace
err.stack = stack.join('\n');
Expand All @@ -475,6 +482,7 @@ describe('Runner', function() {

it('should display the full stack-trace', function(done) {
var hook = new Hook();
hook.parent = suite;
var err = new Error();
// Fake stack-trace
err.stack = stack.join('\n');
Expand Down

0 comments on commit 353ae11

Please sign in to comment.