Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 817e371

Browse files
yangshunfacebook-github-bot
authored andcommitted
Remove Jest auto mocking (#2279)
Summary: **Summary** Saw that the Travis CI is failing because of a new test (`isHTMLBRElement`) which did not explicitly disable auto mocking. In Sandcastle, Jest tests aren't automocked hence the tests passed internally but is failing on GitHub. Since all the tests in the repo have `jest.disableAutomock()`, there's no value in having `automock: true` within `package.json`, we can remove it and save ourselves of this config discrepancy and further pain in future. If we decide to go with this approach then #2278 can be abandoned/closed. **Test Plan** Travis CI should pass. Also check that Sandcastle passes. Pull Request resolved: #2279 Reviewed By: mrkev Differential Revision: D18874249 Pulled By: yangshun fbshipit-source-id: e371558552728b395f67bf1c4d94b127cc3c2c96
1 parent 0603772 commit 817e371

File tree

59 files changed

+2
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2
-111
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
"npm": "2.x || 3.x || 5.x || 6.x"
8888
},
8989
"jest": {
90-
"automock": true,
9190
"globals": {
9291
"__DEV__": true
9392
},

src/component/base/__tests__/DraftEditor.react-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
jest.disableAutomock();
14-
1513
jest.mock('generateRandomKey');
1614

1715
const DraftEditor = require('DraftEditor.react');

src/component/contents/__tests__/DraftEditorBlock.react-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
'use strict';
1212

1313
jest
14-
.disableAutomock()
1514
.mock('Style')
1615
.mock('getElementPosition')
1716
.mock('getScrollPosition')

src/component/contents/__tests__/DraftEditorContents.react-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
jest.disableAutomock();
14-
1513
jest.mock('generateRandomKey');
1614

1715
const Editor = require('DraftEditor.react');

src/component/contents/__tests__/DraftEditorTextNode-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock().mock('UserAgent');
14+
jest.mock('UserAgent');
1515

1616
const BLOCK_DELIMITER_CHAR = '\n';
1717
const TEST_A = 'Hello';

src/component/contents/exploration/__tests__/DraftEditorBlockNode.react-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
'use strict';
1212

1313
jest
14-
.disableAutomock()
1514
.mock('Style')
1615
.mock('getElementPosition')
1716
.mock('getScrollPosition')

src/component/contents/exploration/__tests__/DraftEditorContentsExperimental.react-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
jest.disableAutomock();
14-
1513
const ContentBlockNode = require('ContentBlockNode');
1614
const ContentState = require('ContentState');
1715
const DefaultDraftBlockRenderMap = require('DefaultDraftBlockRenderMap');

src/component/handlers/composition/__tests__/DraftEditorCompostionHandler-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
// DraftEditorComposition uses timers to detect duplicate `compositionend`
1715
// events.
1816
jest.useFakeTimers();

src/component/handlers/edit/__tests__/editOnBeforeInput-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
import type DraftEditor from 'DraftEditor.react';
1715

1816
const CompositeDraftDecorator = require('CompositeDraftDecorator');

src/component/handlers/edit/__tests__/editOnBlur-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const ContentBlock = require('ContentBlock');
1715
const ContentState = require('ContentState');
1816
const EditorState = require('EditorState');

src/component/handlers/edit/__tests__/editOnInput-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const ContentBlock = require('ContentBlock');
1715
const ContentState = require('ContentState');
1816
const EditorState = require('EditorState');

src/component/handlers/edit/commands/__tests__/SecondaryClipboard-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
jest.mock('generateRandomKey');
1715

1816
const toggleExperimentalTreeDataSupport = enabled => {

src/component/handlers/edit/commands/__tests__/removeTextWithStrategy-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
jest.mock('generateRandomKey');
1715

1816
const toggleExperimentalTreeDataSupport = enabled => {

src/component/selection/__tests__/DraftOffsetKey-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* @flow strict-local
1010
*/
1111

12-
jest.disableAutomock();
13-
1412
const DraftOffsetKey = require('DraftOffsetKey');
1513

1614
test('decodes offset key with no delimiter', () => {

src/component/selection/__tests__/getDraftEditorSelection-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
jest.disableAutomock();
14-
1513
const getDraftEditorSelection = require('getDraftEditorSelection');
1614
const getSampleSelectionMocksForTesting = require('getSampleSelectionMocksForTesting');
1715
const getSampleSelectionMocksForTestingNestedBlocks = require('getSampleSelectionMocksForTestingNestedBlocks');

src/component/utils/__tests__/getContentEditableContainer-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
jest.mock('ReactDOM');
1715

1816
const getContentEditableContainer = require('getContentEditableContainer');

src/component/utils/__tests__/isHTMLBRElement-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const isHTMLBRElement = require('isHTMLBRElement');
1715

1816
test('isHTMLBRElement recognizes null', () => {

src/component/utils/exploration/__tests__/DraftTreeAdapter-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
jest.disableAutomock();
14-
1513
jest.mock('generateRandomKey');
1614

1715
const DraftTreeAdapter = require('DraftTreeAdapter');

src/component/utils/exploration/__tests__/DraftTreeInvariants-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
// missing parent -> child connection
1715

1816
const ContentBlockNode = require('ContentBlockNode');

src/model/decorators/__tests__/CompositeDraftDecorator-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @format
99
*/
1010

11-
jest.disableAutomock().mock('ContentState');
11+
jest.mock('ContentState');
1212

1313
const CompositeDraftDecorator = require('CompositeDraftDecorator');
1414
const ContentState = require('ContentState');

src/model/encoding/__tests__/DraftStringKey-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const {stringify, unstringify} = require('DraftStringKey');
1715

1816
test('must convert maybe strings to a string key', () => {

src/model/encoding/__tests__/convertFromDraftStateToRaw-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const BlockMapBuilder = require('BlockMapBuilder');
1715
const CharacterMetadata = require('CharacterMetadata');
1816
const ContentBlock = require('ContentBlock');

src/model/encoding/__tests__/convertFromHTMLToContentBlocks-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
1514
expect.addSnapshotSerializer(require('NonASCIIStringSnapshotSerializer'));
1615

1716
jest.mock('generateRandomKey');

src/model/encoding/__tests__/convertFromRawToDraftState-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
jest.disableAutomock();
14-
1513
jest.mock('generateRandomKey');
1614

1715
const convertFromRawToDraftState = require('convertFromRawToDraftState');

src/model/encoding/__tests__/decodeEntityRanges-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const decodeEntityRanges = require('decodeEntityRanges');
1715

1816
test('must decode when no entities present', () => {

src/model/encoding/__tests__/decodeInlineStyleRanges-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const decodeInlineStyleRanges = require('decodeInlineStyleRanges');
1715

1816
test('must decode for an unstyled block', () => {

src/model/encoding/__tests__/encodeEntityRanges-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const ContentBlock = require('ContentBlock');
1715

1816
const createCharacterList = require('createCharacterList');

src/model/encoding/__tests__/encodeInlineStyleRanges-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const ContentBlock = require('ContentBlock');
1715
const SampleDraftInlineStyle = require('SampleDraftInlineStyle');
1816

src/model/encoding/__tests__/sanitizeDraftText-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* @format
1010
*/
1111

12-
jest.disableAutomock();
13-
1412
const sanitizeDraftText = require('sanitizeDraftText');
1513

1614
test('must strip trailing carriage returns', () => {

src/model/entity/__tests__/DraftEntity-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const DraftEntity = require('DraftEntity');
1715

1816
beforeEach(() => {

src/model/entity/__tests__/getEntityKeyForSelection-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* @format
1010
*/
1111

12-
jest.disableAutomock();
13-
1412
const getEntityKeyForSelection = require('getEntityKeyForSelection');
1513
const getSampleStateForTesting = require('getSampleStateForTesting');
1614

src/model/immutable/__tests__/BlockTree-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
jest.disableAutomock();
14-
1513
const BlockTree = require('BlockTree');
1614
const CharacterMetadata = require('CharacterMetadata');
1715
const ContentBlock = require('ContentBlock');

src/model/immutable/__tests__/CharacterMetadata-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const CharacterMetadata = require('CharacterMetadata');
1715
const {BOLD, BOLD_ITALIC, NONE, UNDERLINE} = require('SampleDraftInlineStyle');
1816

src/model/immutable/__tests__/ContentBlock-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const CharacterMetadata = require('CharacterMetadata');
1715
const ContentBlock = require('ContentBlock');
1816
const {BOLD} = require('SampleDraftInlineStyle');

src/model/immutable/__tests__/ContentBlockNode-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const CharacterMetadata = require('CharacterMetadata');
1715
const ContentBlockNode = require('ContentBlockNode');
1816
const {BOLD, NONE} = require('SampleDraftInlineStyle');

src/model/immutable/__tests__/ContentState-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
jest.mock('SelectionState');
1715

1816
let contentState;

src/model/immutable/__tests__/EditorBidiService-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const ContentBlock = require('ContentBlock');
1715
const ContentState = require('ContentState');
1816
const EditorBidiService = require('EditorBidiService');

src/model/immutable/__tests__/EditorState-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
'use strict';
1212

13-
jest.disableAutomock();
14-
1513
const CharacterMetadata = require('CharacterMetadata');
1614
const ContentBlock = require('ContentBlock');
1715
const ContentState = require('ContentState');

src/model/immutable/__tests__/SelectionState-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const SelectionState = require('SelectionState');
1715

1816
const DEFAULT_CONFIG = {

src/model/immutable/__tests__/findRangesImmutable-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
const findRangesImmutable = require('findRangesImmutable');
1715
const Immutable = require('immutable');
1816

src/model/modifier/__tests__/AtomicBlockUtils-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
jest.mock('generateRandomKey');
1715

1816
const AtomicBlockUtils = require('AtomicBlockUtils');

src/model/modifier/__tests__/DraftRemovableWord-test.js

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
1514
expect.addSnapshotSerializer(require('NonASCIIStringSnapshotSerializer'));
1615

1716
const DraftRemovableWord = require('DraftRemovableWord');

src/model/modifier/__tests__/RichTextEditorUtil-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* @format
99
*/
1010

11-
jest.disableAutomock();
12-
1311
const AtomicBlockUtils = require('AtomicBlockUtils');
1412
const DraftModifier = require('DraftModifier');
1513
const EditorState = require('EditorState');

src/model/modifier/exploration/__tests__/DraftTreeOperations-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
'use strict';
1313

14-
jest.disableAutomock();
15-
1614
jest.mock('generateRandomKey');
1715

1816
const ContentBlockNode = require('ContentBlockNode');

src/model/modifier/exploration/__tests__/NestedRichTextEditorUtil-test.js

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* @format
99
*/
1010

11-
jest.disableAutomock();
12-
1311
jest.mock('generateRandomKey');
1412

1513
const AtomicBlockUtils = require('AtomicBlockUtils');

0 commit comments

Comments
 (0)