Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
captbaritone committed May 27, 2018
1 parent 79971b3 commit cc417a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Object {
Test suite failed to run
thrown: \\"Invalid: beforeEach() in a describe block with no tests.\\"
Invalid: beforeEach() may not be used in a describe block containing no tests.
7 |
8 | describe('a block', () => {
Expand Down Expand Up @@ -37,7 +37,7 @@ Object {
Test suite failed to run
thrown: \\"Invalid: beforeEach() in a describe block with no tests.\\"
Invalid: beforeEach() may not be used in a describe block containing no tests.
7 |
8 | describe('a block', () => {
Expand Down Expand Up @@ -67,7 +67,7 @@ Object {
Test suite failed to run
thrown: \\"Invalid: beforeEach() in a describe block with no tests.\\"
Invalid: beforeEach() may not be used in a describe block containing no tests.
7 |
8 | describe('a block', () => {
Expand All @@ -82,7 +82,7 @@ Object {
Test suite failed to run
thrown: \\"Invalid: afterEach() in a describe block with no tests.\\"
Invalid: afterEach() may not be used in a describe block containing no tests.
8 | describe('a block', () => {
9 | beforeEach(() => {});
Expand All @@ -97,7 +97,7 @@ Object {
Test suite failed to run
thrown: \\"Invalid: afterAll() in a describe block with no tests.\\"
Invalid: afterAll() may not be used in a describe block containing no tests.
9 | beforeEach(() => {});
10 | afterEach(() => {});
Expand All @@ -112,7 +112,7 @@ Object {
Test suite failed to run
thrown: \\"Invalid: beforeAll() in a describe block with no tests.\\"
Invalid: beforeAll() may not be used in a describe block containing no tests.
10 | afterEach(() => {});
11 | afterAll(() => {});
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-circus/src/event_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ const handler: EventHandler = (event, state): void => {

if (!describeBlockHasTests(currentDescribeBlock)) {
currentDescribeBlock.hooks.forEach(hook => {
state.unhandledErrors.push([
`Invalid: ${hook.type}() in a describe block with no tests.`,
hook.asyncError,
]);
hook.asyncError.message = `Invalid: ${
hook.type
}() may not be used in a describe block containing no tests.`;
state.unhandledErrors.push(hook.asyncError);
});
}

Expand Down

0 comments on commit cc417a2

Please sign in to comment.