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

Commit

Permalink
Remove Jest auto mocking (#2279)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yangshun authored and facebook-github-bot committed Dec 10, 2019
1 parent 0603772 commit 817e371
Show file tree
Hide file tree
Showing 59 changed files with 2 additions and 111 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"npm": "2.x || 3.x || 5.x || 6.x"
},
"jest": {
"automock": true,
"globals": {
"__DEV__": true
},
Expand Down
2 changes: 0 additions & 2 deletions src/component/base/__tests__/DraftEditor.react-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

jest.disableAutomock();

jest.mock('generateRandomKey');

const DraftEditor = require('DraftEditor.react');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'use strict';

jest
.disableAutomock()
.mock('Style')
.mock('getElementPosition')
.mock('getScrollPosition')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

jest.disableAutomock();

jest.mock('generateRandomKey');

const Editor = require('DraftEditor.react');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

'use strict';

jest.disableAutomock().mock('UserAgent');
jest.mock('UserAgent');

const BLOCK_DELIMITER_CHAR = '\n';
const TEST_A = 'Hello';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'use strict';

jest
.disableAutomock()
.mock('Style')
.mock('getElementPosition')
.mock('getScrollPosition')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

jest.disableAutomock();

const ContentBlockNode = require('ContentBlockNode');
const ContentState = require('ContentState');
const DefaultDraftBlockRenderMap = require('DefaultDraftBlockRenderMap');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

// DraftEditorComposition uses timers to detect duplicate `compositionend`
// events.
jest.useFakeTimers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

import type DraftEditor from 'DraftEditor.react';

const CompositeDraftDecorator = require('CompositeDraftDecorator');
Expand Down
2 changes: 0 additions & 2 deletions src/component/handlers/edit/__tests__/editOnBlur-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const ContentBlock = require('ContentBlock');
const ContentState = require('ContentState');
const EditorState = require('EditorState');
Expand Down
2 changes: 0 additions & 2 deletions src/component/handlers/edit/__tests__/editOnInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const ContentBlock = require('ContentBlock');
const ContentState = require('ContentState');
const EditorState = require('EditorState');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

jest.mock('generateRandomKey');

const toggleExperimentalTreeDataSupport = enabled => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

jest.mock('generateRandomKey');

const toggleExperimentalTreeDataSupport = enabled => {
Expand Down
2 changes: 0 additions & 2 deletions src/component/selection/__tests__/DraftOffsetKey-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* @flow strict-local
*/

jest.disableAutomock();

const DraftOffsetKey = require('DraftOffsetKey');

test('decodes offset key with no delimiter', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

jest.disableAutomock();

const getDraftEditorSelection = require('getDraftEditorSelection');
const getSampleSelectionMocksForTesting = require('getSampleSelectionMocksForTesting');
const getSampleSelectionMocksForTestingNestedBlocks = require('getSampleSelectionMocksForTestingNestedBlocks');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

jest.mock('ReactDOM');

const getContentEditableContainer = require('getContentEditableContainer');
Expand Down
2 changes: 0 additions & 2 deletions src/component/utils/__tests__/isHTMLBRElement-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const isHTMLBRElement = require('isHTMLBRElement');

test('isHTMLBRElement recognizes null', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

jest.disableAutomock();

jest.mock('generateRandomKey');

const DraftTreeAdapter = require('DraftTreeAdapter');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

// missing parent -> child connection

const ContentBlockNode = require('ContentBlockNode');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @format
*/

jest.disableAutomock().mock('ContentState');
jest.mock('ContentState');

const CompositeDraftDecorator = require('CompositeDraftDecorator');
const ContentState = require('ContentState');
Expand Down
2 changes: 0 additions & 2 deletions src/model/encoding/__tests__/DraftStringKey-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const {stringify, unstringify} = require('DraftStringKey');

test('must convert maybe strings to a string key', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const BlockMapBuilder = require('BlockMapBuilder');
const CharacterMetadata = require('CharacterMetadata');
const ContentBlock = require('ContentBlock');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

'use strict';

jest.disableAutomock();
expect.addSnapshotSerializer(require('NonASCIIStringSnapshotSerializer'));

jest.mock('generateRandomKey');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

jest.disableAutomock();

jest.mock('generateRandomKey');

const convertFromRawToDraftState = require('convertFromRawToDraftState');
Expand Down
2 changes: 0 additions & 2 deletions src/model/encoding/__tests__/decodeEntityRanges-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const decodeEntityRanges = require('decodeEntityRanges');

test('must decode when no entities present', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/model/encoding/__tests__/decodeInlineStyleRanges-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const decodeInlineStyleRanges = require('decodeInlineStyleRanges');

test('must decode for an unstyled block', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/model/encoding/__tests__/encodeEntityRanges-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const ContentBlock = require('ContentBlock');

const createCharacterList = require('createCharacterList');
Expand Down
2 changes: 0 additions & 2 deletions src/model/encoding/__tests__/encodeInlineStyleRanges-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const ContentBlock = require('ContentBlock');
const SampleDraftInlineStyle = require('SampleDraftInlineStyle');

Expand Down
2 changes: 0 additions & 2 deletions src/model/encoding/__tests__/sanitizeDraftText-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* @format
*/

jest.disableAutomock();

const sanitizeDraftText = require('sanitizeDraftText');

test('must strip trailing carriage returns', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/model/entity/__tests__/DraftEntity-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const DraftEntity = require('DraftEntity');

beforeEach(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/model/entity/__tests__/getEntityKeyForSelection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* @format
*/

jest.disableAutomock();

const getEntityKeyForSelection = require('getEntityKeyForSelection');
const getSampleStateForTesting = require('getSampleStateForTesting');

Expand Down
2 changes: 0 additions & 2 deletions src/model/immutable/__tests__/BlockTree-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

jest.disableAutomock();

const BlockTree = require('BlockTree');
const CharacterMetadata = require('CharacterMetadata');
const ContentBlock = require('ContentBlock');
Expand Down
2 changes: 0 additions & 2 deletions src/model/immutable/__tests__/CharacterMetadata-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const CharacterMetadata = require('CharacterMetadata');
const {BOLD, BOLD_ITALIC, NONE, UNDERLINE} = require('SampleDraftInlineStyle');

Expand Down
2 changes: 0 additions & 2 deletions src/model/immutable/__tests__/ContentBlock-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const CharacterMetadata = require('CharacterMetadata');
const ContentBlock = require('ContentBlock');
const {BOLD} = require('SampleDraftInlineStyle');
Expand Down
2 changes: 0 additions & 2 deletions src/model/immutable/__tests__/ContentBlockNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const CharacterMetadata = require('CharacterMetadata');
const ContentBlockNode = require('ContentBlockNode');
const {BOLD, NONE} = require('SampleDraftInlineStyle');
Expand Down
2 changes: 0 additions & 2 deletions src/model/immutable/__tests__/ContentState-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

jest.mock('SelectionState');

let contentState;
Expand Down
2 changes: 0 additions & 2 deletions src/model/immutable/__tests__/EditorBidiService-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const ContentBlock = require('ContentBlock');
const ContentState = require('ContentState');
const EditorBidiService = require('EditorBidiService');
Expand Down
2 changes: 0 additions & 2 deletions src/model/immutable/__tests__/EditorState-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

'use strict';

jest.disableAutomock();

const CharacterMetadata = require('CharacterMetadata');
const ContentBlock = require('ContentBlock');
const ContentState = require('ContentState');
Expand Down
2 changes: 0 additions & 2 deletions src/model/immutable/__tests__/SelectionState-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const SelectionState = require('SelectionState');

const DEFAULT_CONFIG = {
Expand Down
2 changes: 0 additions & 2 deletions src/model/immutable/__tests__/findRangesImmutable-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

const findRangesImmutable = require('findRangesImmutable');
const Immutable = require('immutable');

Expand Down
2 changes: 0 additions & 2 deletions src/model/modifier/__tests__/AtomicBlockUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

jest.mock('generateRandomKey');

const AtomicBlockUtils = require('AtomicBlockUtils');
Expand Down
1 change: 0 additions & 1 deletion src/model/modifier/__tests__/DraftRemovableWord-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

'use strict';

jest.disableAutomock();
expect.addSnapshotSerializer(require('NonASCIIStringSnapshotSerializer'));

const DraftRemovableWord = require('DraftRemovableWord');
Expand Down
2 changes: 0 additions & 2 deletions src/model/modifier/__tests__/RichTextEditorUtil-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

jest.disableAutomock();

const AtomicBlockUtils = require('AtomicBlockUtils');
const DraftModifier = require('DraftModifier');
const EditorState = require('EditorState');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

'use strict';

jest.disableAutomock();

jest.mock('generateRandomKey');

const ContentBlockNode = require('ContentBlockNode');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @format
*/

jest.disableAutomock();

jest.mock('generateRandomKey');

const AtomicBlockUtils = require('AtomicBlockUtils');
Expand Down
Loading

0 comments on commit 817e371

Please sign in to comment.