-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Jest Circus] Make hooks in empty describe blocks error
Fixes #6293
- Loading branch information
1 parent
a43fd6c
commit 78de4d1
Showing
11 changed files
with
334 additions
and
1 deletion.
There are no files selected for viewing
142 changes: 142 additions & 0 deletions
142
integration-tests/__tests__/__snapshots__/empty-describe-with-hooks.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`hook in empty describe 1`] = ` | ||
Object { | ||
"rest": "FAIL __tests__/hook-in-empty-describe.test.js | ||
● Test suite failed to run | ||
thrown: \\"Invalid: beforeEach() in a describe block with no tests.\\" | ||
7 | | ||
8 | describe('a block', () => { | ||
> 9 | beforeEach(() => {}); | ||
| ^ | ||
10 | }); | ||
11 | | ||
12 | describe('another block with tests', () => { | ||
at packages/jest-circus/build/index.js:33:17 | ||
at __tests__/hook-in-empty-describe.test.js:9:3 | ||
at __tests__/hook-in-empty-describe.test.js:8:1 | ||
", | ||
"summary": "Test Suites: 1 failed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites matching /hook-in-empty-describe.test.js/i. | ||
", | ||
} | ||
`; | ||
exports[`hook in empty nested describe 1`] = ` | ||
Object { | ||
"rest": "FAIL __tests__/hook-in-empty-nested-describe.test.js | ||
● Test suite failed to run | ||
thrown: \\"Invalid: beforeEach() in a describe block with no tests.\\" | ||
7 | | ||
8 | describe('a block', () => { | ||
> 9 | beforeEach(() => {}); | ||
| ^ | ||
10 | describe('another block', () => {}); | ||
11 | }); | ||
12 | | ||
at packages/jest-circus/build/index.js:33:17 | ||
at __tests__/hook-in-empty-nested-describe.test.js:9:3 | ||
at __tests__/hook-in-empty-nested-describe.test.js:8:1 | ||
", | ||
"summary": "Test Suites: 1 failed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites matching /hook-in-empty-nested-describe.test.js/i. | ||
", | ||
} | ||
`; | ||
exports[`multiple hooks in empty describe 1`] = ` | ||
Object { | ||
"rest": "FAIL __tests__/multiple-hooks-in-empty-describe.test.js | ||
● Test suite failed to run | ||
thrown: \\"Invalid: beforeEach() in a describe block with no tests.\\" | ||
7 | | ||
8 | describe('a block', () => { | ||
> 9 | beforeEach(() => {}); | ||
| ^ | ||
10 | afterEach(() => {}); | ||
11 | afterAll(() => {}); | ||
12 | beforeAll(() => {}); | ||
at packages/jest-circus/build/index.js:33:17 | ||
at __tests__/multiple-hooks-in-empty-describe.test.js:9:3 | ||
at __tests__/multiple-hooks-in-empty-describe.test.js:8:1 | ||
● Test suite failed to run | ||
thrown: \\"Invalid: afterEach() in a describe block with no tests.\\" | ||
8 | describe('a block', () => { | ||
9 | beforeEach(() => {}); | ||
> 10 | afterEach(() => {}); | ||
| ^ | ||
11 | afterAll(() => {}); | ||
12 | beforeAll(() => {}); | ||
13 | }); | ||
at packages/jest-circus/build/index.js:33:17 | ||
at __tests__/multiple-hooks-in-empty-describe.test.js:10:3 | ||
at __tests__/multiple-hooks-in-empty-describe.test.js:8:1 | ||
● Test suite failed to run | ||
thrown: \\"Invalid: afterAll() in a describe block with no tests.\\" | ||
9 | beforeEach(() => {}); | ||
10 | afterEach(() => {}); | ||
> 11 | afterAll(() => {}); | ||
| ^ | ||
12 | beforeAll(() => {}); | ||
13 | }); | ||
14 | | ||
at packages/jest-circus/build/index.js:33:17 | ||
at __tests__/multiple-hooks-in-empty-describe.test.js:11:3 | ||
at __tests__/multiple-hooks-in-empty-describe.test.js:8:1 | ||
● Test suite failed to run | ||
thrown: \\"Invalid: beforeAll() in a describe block with no tests.\\" | ||
10 | afterEach(() => {}); | ||
11 | afterAll(() => {}); | ||
> 12 | beforeAll(() => {}); | ||
| ^ | ||
13 | }); | ||
14 | | ||
15 | describe('another block with tests', () => { | ||
at packages/jest-circus/build/index.js:33:17 | ||
at __tests__/multiple-hooks-in-empty-describe.test.js:12:3 | ||
at __tests__/multiple-hooks-in-empty-describe.test.js:8:1 | ||
", | ||
"summary": "Test Suites: 1 failed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites matching /multiple-hooks-in-empty-describe.test.js/i. | ||
", | ||
} | ||
`; |
36 changes: 36 additions & 0 deletions
36
integration-tests/__tests__/empty-describe-with-hooks.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2018-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
const runJest = require('../runJest'); | ||
const {extractSummary} = require('../Utils'); | ||
const dir = path.resolve(__dirname, '../empty-describe-with-hooks'); | ||
const ConditionalTest = require('../../scripts/ConditionalTest'); | ||
|
||
ConditionalTest.skipSuiteOnJasmine(); | ||
|
||
test('hook in empty describe', () => { | ||
const result = runJest(dir, ['hook-in-empty-describe.test.js']); | ||
expect(result.status).toBe(1); | ||
expect(extractSummary(result.stderr)).toMatchSnapshot(); | ||
}); | ||
|
||
test('hook in empty nested describe', () => { | ||
const result = runJest(dir, ['hook-in-empty-nested-describe.test.js']); | ||
expect(result.status).toBe(1); | ||
expect(extractSummary(result.stderr)).toMatchSnapshot(); | ||
}); | ||
|
||
test('multiple hooks in empty describe', () => { | ||
const result = runJest(dir, ['multiple-hooks-in-empty-describe.test.js']); | ||
expect(result.status).toBe(1); | ||
expect(extractSummary(result.stderr)).toMatchSnapshot(); | ||
}); |
14 changes: 14 additions & 0 deletions
14
integration-tests/empty-describe-with-hooks/__tests__/hook-in-empty-describe.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) 2018-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
describe('a block', () => { | ||
beforeEach(() => {}); | ||
}); | ||
|
||
describe('another block with tests', () => { | ||
test('this test prevents us from failing due to zero tests', () => {}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
integration-tests/empty-describe-with-hooks/__tests__/hook-in-empty-nested-describe.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Copyright (c) 2018-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
describe('a block', () => { | ||
beforeEach(() => {}); | ||
describe('another block', () => {}); | ||
}); | ||
|
||
describe('another block with tests', () => { | ||
test('this test prevents us from failing due to zero tests', () => {}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
...ration-tests/empty-describe-with-hooks/__tests__/multiple-hooks-in-empty-describe.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2018-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
describe('a block', () => { | ||
beforeEach(() => {}); | ||
afterEach(() => {}); | ||
afterAll(() => {}); | ||
beforeAll(() => {}); | ||
}); | ||
|
||
describe('another block with tests', () => { | ||
test('this test prevents us from failing due to zero tests', () => {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
packages/jest-circus/src/__tests__/__snapshots__/after_all-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters