-
-
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.
Allow errorOnDeprecated to error on DEFAULT_TIMEOUT_INTERVAL (#6367)
- Loading branch information
1 parent
12d91ad
commit 00a8117
Showing
10 changed files
with
192 additions
and
7 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
e2e/__tests__/__snapshots__/error-on-deprecated.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`can read and write jasmine.DEFAULT_TIMEOUT_INTERVAL 1`] = ` | ||
"Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites." | ||
`; | ||
exports[`does not exceed the timeout using jasmine.DEFAULT_TIMEOUT_INTERVAL 1`] = ` | ||
"PASS __tests__/a-banana.js | ||
✓ banana | ||
" | ||
`; | ||
exports[`does not exceed the timeout using jasmine.DEFAULT_TIMEOUT_INTERVAL 2`] = ` | ||
"Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites." | ||
`; | ||
exports[`exceeds the timeout set using jasmine.DEFAULT_TIMEOUT_INTERVAL 1`] = ` | ||
"Test Suites: 1 failed, 1 total | ||
Tests: 1 failed, 1 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites. | ||
" | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** | ||
* Copyright (c) 2014-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 {extractSummary, cleanup, writeFiles} = require('../Utils'); | ||
const runJest = require('../runJest'); | ||
const ConditionalTest = require('../../scripts/ConditionalTest'); | ||
|
||
/** | ||
* NOTE: This test should be removed once jest-circus is rolled out as a breaking change. | ||
*/ | ||
|
||
const DIR = path.resolve(__dirname, '../timeouts-legacy'); | ||
|
||
ConditionalTest.skipSuiteOnJestCircus(); | ||
|
||
beforeEach(() => cleanup(DIR)); | ||
afterAll(() => cleanup(DIR)); | ||
|
||
test('exceeds the timeout set using jasmine.DEFAULT_TIMEOUT_INTERVAL', () => { | ||
writeFiles(DIR, { | ||
'__tests__/a-banana.js': ` | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20; | ||
test('banana', () => { | ||
return new Promise(resolve => { | ||
setTimeout(resolve, 100); | ||
}); | ||
}); | ||
`, | ||
'package.json': '{}', | ||
}); | ||
|
||
const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false']); | ||
const {rest, summary} = extractSummary(stderr); | ||
expect(rest).toMatch( | ||
/(jest\.setTimeout|jasmine\.DEFAULT_TIMEOUT_INTERVAL|Exceeded timeout)/, | ||
); | ||
expect(summary).toMatchSnapshot(); | ||
expect(status).toBe(1); | ||
}); | ||
|
||
test('does not exceed the timeout using jasmine.DEFAULT_TIMEOUT_INTERVAL', () => { | ||
writeFiles(DIR, { | ||
'__tests__/a-banana.js': ` | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; | ||
test('banana', () => { | ||
return new Promise(resolve => { | ||
setTimeout(resolve, 20); | ||
}); | ||
}); | ||
`, | ||
'package.json': '{}', | ||
}); | ||
|
||
const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false']); | ||
const {rest, summary} = extractSummary(stderr); | ||
expect(rest).toMatchSnapshot(); | ||
expect(summary).toMatchSnapshot(); | ||
expect(status).toBe(0); | ||
}); | ||
|
||
test('can read and write jasmine.DEFAULT_TIMEOUT_INTERVAL', () => { | ||
writeFiles(DIR, { | ||
'__tests__/a-banana.js': ` | ||
const timeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 154; | ||
const newTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | ||
test('banana', () => { | ||
expect(timeout).toBe(5000); | ||
expect(newTimeout).toBe(154); | ||
}); | ||
`, | ||
'package.json': '{}', | ||
}); | ||
|
||
const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false']); | ||
const {summary} = extractSummary(stderr); | ||
expect(summary).toMatchSnapshot(); | ||
expect(status).toBe(0); | ||
}); |
12 changes: 12 additions & 0 deletions
12
e2e/error-on-deprecated/__tests__/DEFAULT_TIMEOUT_INTERVAL.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,12 @@ | ||
/** | ||
* Copyright (c) 2014-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. | ||
*/ | ||
'use strict'; | ||
|
||
test('DEFAULT_TIMEOUT_INTERVAL', () => { | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; | ||
expect(true).toBe(true); | ||
}); |
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